function Leapyear (year:word):boolean;
begin
if (year mod 4 =0) and (year mod 100 <>0)
or (year mod 400 =0) then Leapyear:=true
else Leapyear:=false;
end;

function correctDate
(day,mon,year:integer):boolean;
var maxday:integer;
begin
if (year<0) or (mon<1) or (mon>12) or (day<1) then correctDate:=false
else begin
maxday:=mondays[mon];
if (Leapyear (year)=true) and (mon=2) then maxday:=29;
if (day>maxday) then correctDate:=false
else correctDate:=true;
end;
end;

function KolDays (d1,m1,d2,m2,y:word):word;
var i,f,s:word;
begin
s:=0;
if m1=m2 then KolDays:=d2-d1
else for i:=m1 to m2 do begin
f:=mondays[i];
if (Leapyear (y)=true) and (i=2)
then f:=f+1;
if i=m1 then s:=s+(f-d1+1)
else if i=m2 then s:=s+d2
else s:=s+f;
KolDays:=s;
end;
end;

function countDays (day1, mon1, year1,
day2, mon2, year2:word):word;
var f,i:word;
begin
f:=0;
if year1=year2 then countDays:= KolDays (day1, mon1, day2, mon2, year1)
else for i:=year1 to year2 do begin

if i=year1 then f:=KolDays (day1, mon1, 31, 12, year1)
else if i=year2 then f:=f+ KolDays (1,1,day2,mon2,year2)-1
else f:=f+KolDays (1,1,31,12,i);
countDays:=f;
end;
end;

begin
getdate (y2,m2,d2,d);
writeln ('Год Вашего рождения?');
readln (y1);
writeln ('Месяц Вашего рождения?');
readln (m1);
writeln ('День Вашего рождения?');
readln (d1);
if correctDate (d1,m1,y1)=false then begin
writeln ('Недопустимая дата!'); halt;
end;
if (y2 then begin writeln ('Введенная дата',' позднее сегодняшней!');
halt;
end;
d:=countDays (d1,m1,y1,d2,m2,y2);
writeln ('Количество дней= ',d);
end.

Оценка - 1.0 (13)

2010-07-17 • Просмотров [ 2204 ]