Var a,d,count,i:integer; function CountDay(a:integer):integer; begin if (a>=1) then countday:=31; if (a>=2) then countday:=28; if (a>=3) then countday:=31; if (a>=4) then countday:=30; if (a>=5) then countday:=31; if (a>=6) then countday:=30; if (a>=7) then countday:=31; if (a>=8) then countday:=31; if (a>=9) then countday:=30; if (a>=10) then countday:=31; if (a>=11) then countday:=30; if (a>=12) then countday:=31; end; begin count:=0; write('Введите День: '); readln(d); write('Введите Месяц: '); readln(a); if (a<=0)or(a>12)or(d<=0)or(d>countday(a)) then writeln('Ошшибка в данных! ') else begin for i:=a to 12 do count:=count+countday(i); count:=count-d; writeln('До нового года осталось ',count,' дней'); end; end.
В программе буквы добавляются по алфавиту без повторений. var s1,s2:string; function F(var a,b:string):boolean; var m:set of char; i:integer; c:char; begin m:=[]; for i:=1 to length(a) do if pos(a[i],b)=0 then m:=m+[a[i]]; for c:=chr(32) to chr(255) do if c in m then a:=a+c; if m=[] then f:=false else f:=true; end; begin writeln('Введите строку 1:'); readln(s1); writeln('Введите строку 2:'); readln(s2); if f(s1,s2) then writeln('Новая строка: ',s1) else writeln('Строка не изменилась ');end.
Пример: Введите строку 1: program Введите строку 2: procedure Новая строка: programagm
function CountDay(a:integer):integer;
begin
if (a>=1) then countday:=31;
if (a>=2) then countday:=28;
if (a>=3) then countday:=31;
if (a>=4) then countday:=30;
if (a>=5) then countday:=31;
if (a>=6) then countday:=30;
if (a>=7) then countday:=31;
if (a>=8) then countday:=31;
if (a>=9) then countday:=30;
if (a>=10) then countday:=31;
if (a>=11) then countday:=30;
if (a>=12) then countday:=31;
end;
begin
count:=0;
write('Введите День: ');
readln(d);
write('Введите Месяц: ');
readln(a);
if (a<=0)or(a>12)or(d<=0)or(d>countday(a)) then
writeln('Ошшибка в данных! ')
else
begin
for i:=a to 12 do
count:=count+countday(i);
count:=count-d;
writeln('До нового года осталось ',count,' дней');
end;
end.