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.
// PascalABC.NET 3.1, сборка 1200 от 13.03.2016 function IsPrime(n:integer):boolean; begin if n<4 then Result:=True else begin var found:= (n mod 2 = 0); var p:=3; while (not found) and (sqr(p)<=n) do begin found:=(n mod p = 0); p+=2 end; Result:=not found end end;
begin Writeln('k=',ArrRandom(ReadInteger('n='),1,999).Println. Where(x->IsPrime(x)).Count) end.
// PascalABC.NET 3.1, сборка 1200 от 13.03.2016 procedure IsPrime(n:integer; var res:boolean); begin if n<4 then res:=True else begin var found:= (n mod 2 = 0); var p:=3; while (not found) and (sqr(p)<=n) do begin found:=(n mod p = 0); p+=2 end; res:=not found end end;
begin var a:=ArrRandom(ReadInteger('n='),1,999); a.Println; var k:=0; var prime:boolean; foreach var e in a do begin IsPrime(e,prime); if Prime then Inc(k) end; Writeln('k=',k) end.
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.