Advertisement
huyhung94

Xem ngày tiếp theo

Nov 1st, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.22 KB | None | 0 0
  1. program bt;
  2. Uses Crt;
  3. var ngay, thang, nam:integer;
  4.     namnhuan:Boolean;
  5. Begin
  6.      Clrscr;
  7.      write('Nhap ngay, thang, nam:=');
  8.      readln(ngay,thang,nam);
  9.   If ((nam MOD 400=0) or ((nam mod 4=0) and (nam mod 100<>0)))
  10.       then (namnhuan):=True
  11.   else namnhuan:=False;
  12.   Case thang OF
  13.       1,3,5,7,8,10,12:if ngay=31 then
  14.                          begin
  15.                               ngay:=1;
  16.                               thang:=thang+1;
  17.                          end
  18.                        else inc(ngay);
  19.      2: If (namnhuan) then
  20.            begin
  21.                 if ngay=29 then
  22.                    begin
  23.                      ngay:=1;
  24.                      thang:=3;
  25.                 end else inc(ngay);
  26.            end
  27.          else if (ngay=28) then
  28.               begin
  29.                    ngay:=1;
  30.                    thang:=3;
  31.               end else inc(ngay);
  32.       4,6,9,11: if(ngay=30) then
  33.                   begin
  34.                       ngay:=1;
  35.                       inc(thang);
  36.                   end
  37.                  else inc(ngay);
  38.  end;
  39.   If thang > 12 then
  40.      begin
  41.           nam:=nam+1;
  42.           thang:=1;
  43.      end;
  44.  writeln('Ngay hom sau la: ',ngay,' ', thang,' ', nam);
  45.  readln;
  46. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement