program count_days;
var
a, b, c, x, y, z, days: integer;
function is_leap_year(year: integer): boolean;
begin
if (year mod 4 = 0) and (year mod 100 <> 0) or (year mod 400 = 0) then
is_leap_year := true
else
is_leap_year := false;
end;
function days_in_month(month, year: integer): integer;
begin
case month of
1, 3, 5, 7, 8, 10, 12: days_in_month := 31;
4, 6, 9, 11: days_in_month := 30;
2:
if is_leap_year(year) then
days_in_month := 29
else
days_in_month := 28;
end;
end;
begin
writeln('Nhap ngay a thang b nam c: ');
readln(a, b, c);
writeln('Nhap ngay x thang y cung nam c: ');
readln(x, y, z);
if (a > x) or ((a = x) and (b > y)) or ((a = x) and (b = y) and (c > z)) then
begin
writeln('Loi nhap lieu!');
halt;
end;
days := days_in_month(b, c) - a + 1;
while (b < y) or ((b = y) and (c < z)) do
begin
a := 1;
b := b + 1;
if b > 12 then
begin
b := 1;
c := c + 1;
end;
days := days + days_in_month(b, c);
end;
days := days - (days_in_month(y, z) - x);
writeln('So ngay giua hai ngay la: ', days);
end.
Dữ liệu ra: số ngày tương ứng