Скільки днів пройшло від початку року

Program k_dniv;

Uses crt;

Var d,m,r,lutyj,k: integer;

Begin

Clrscr;

Readln(d, m, r);

If ((r mod 4=0) and (r mod 100<>0)) or (r mod 400=0) then lutyj:=29 else lutyj:=28;

If  m=1 then k:=d;

If  m=2 then k:=31+d;

If  m=3 then k:=31+ lutyj+d;

If  m=4 then k:=31+ lutyj+31+d;

If  m=5 then k:=31+ lutyj+31+30+d;

If  m=6 then k:=31+ lutyj+31+30+31+d;

If  m=7 then k:=31+ lutyj+31+30+31+30+d;

If  m=8 then k:= 31+ lutyj+31+30+31+30+31+d;

If  m=9 then k:= 31+ lutyj+31+30+31+30+31+31+d;

If  m=10 then k:= 31+ lutyj+31+30+31+30+31+31+30+d;

If  m=11 then k:= 31+ lutyj+31+30+31+30+31+31+30+31+d;

If  m=12  then k:= 31+ lutyj+31+30+31+30+31+31+30+31+30+d;

Writeln(‘k=’,k);readln;

End.

Наступна дата

program nastupna_data;

var

   d,m,r,lutyj: integer;

begin

     write(' day '); readln(d);

     write(' month '); readln(m);

     write(' year '); readln(r);

     if ((r mod 4=0) and (r mod 100 <>0) or (r mod 400 =0))

        then lutyj:=29 else lutyj:=28;

     if ((m=1) and (d=31)) then begin m:=m+1; d:=0; end;

     if ((m=2) and (lutyj=29) and(d=29)) then begin m:=m+1; d:=0; end;

     if ((m=2) and (lutyj=28) and(d=28)) then begin m:=m+1; d:=0; end;

     if ((m=3) and (d=31)) then begin m:=m+1; d:=0; end;

     if ((m=4) and (d=30)) then begin m:=m+1; d:=0; end;

     if ((m=5) and (d=31)) then begin m:=m+1; d:=0; end;

     if ((m=6) and (d=30)) then begin m:=m+1; d:=0; end;

     if ((m=7) and (d=31)) then begin m:=m+1; d:=0; end;

     if ((m=8) and (d=31)) then begin m:=m+1; d:=0; end;

     if ((m=9) and (d=30)) then begin m:=m+1; d:=0; end;

     if ((m=10) and (d=31)) then begin m:=m+1; d:=0; end;

     if ((m=11) and (d=30)) then begin m:=m+1; d:=0; end;

     if ((m=12) and (d=31)) then begin m:=1; d:=1; r:=r+1 end

         else d:=d+1;

     writeln ('Наступна дата=',d,'.',m,'.',r);

readln;

end.

 

Самостійне завдання:

1.     Скільки днів залишилось до кінця року.

2.     Визначення попередньої дати.

 

 

Хостинг от uCoz