a263.
日期差幾天
--
板橋高中練習題
| From: [112.64.189.234] |
發表日期
:
2014-01-30 22:30
var
year:array[1..2] of longint;
month:array[1..2] of 1..13;
day:array[1..2] of 1..32;
days:longint;
i,t:longint;
function min(a,b:longint):longint;
begin
if year[1]<year[2] then
min:=1
else
if year[1]>year[2] then
min:=2
else
if year[1]=year[2] then
if month[1]<month[2] then
min:=1
else
if month[1]>month[2] then
min:=2
else
if month[1]=month[2] then
if day[1]<day[2] then
min:=1
else
min:=2;
end;
function leap(year:longint):boolean;
begin
if ((year mod 4=0) and (year mod 100<>0)) or (year mod 400=0) then
leap:=true
else
leap:=false;
end;
function should(a:longint):longint;
begin
case a of
1,3,5,7,8,10,12: should:=31;
4,6,9,11: should:=30;
2: if leap(year[t])=true then
should:=29
else
should:=28;
end;
end;
begin
while not eof do
begin
days:=0;
for i:=1 to 2 do
readln(year[i],month[i],day[i]);
t:=min(1,2);
while (year[1]<>year[2]) or (month[1]<>month[2]) or (day[1]<>day[2]) do
begin
inc(days);
inc(day[t]);
if should(month[t])<day[t] then
begin
inc(month[t]);
day[t]:=1;
end;
if month[t]=13 then
begin
inc(year[t]);
month[t]:=1;
end;
end;
writeln(days);
end;
end.