var s:string; d1,m1,g1,d2,m2,g2,t,c:integer; p:boolean; k:byte;begin
k:=0;
writeln('Введите дату в формате дд.мм.гг');readln(s); val(copy(s,7,2),t,c);{преобразуем год в число}if (c<>0)or(t<0) then k:=1 else g1:=t;{определим високосный год или нет}if (((g1+2000) mod 100<>0)and((g1+2000) mod 4=0))or((g1+2000) mod 400=0) then p:=trueelse p:=false;
val(copy(s,4,2),t,c);if (c<>0)or not(t in [1..12]) then k:=1 else m1:=t;
val(copy(s,1,2),t,c);if (c<>0)or((m1 in [1,3,5,7,8,10,12])and not(t in [1..31])) or((m1 in [4,6,9,11])and not(t in [1..30])) or(p and(m1=2)and not(t in [1..29])) or(not p and(m1=2)and not(t in [1..28]))then k:=1 else d1:=t;if k=1 thenbeginwriteln('Дата введена неверно!');endelsebeginif(m1=1)and(d1=1)then begin d2:=31; m2:=12; g2:=g1-1; end
else if ((m1 in [5,7,10,12]) and(d1=1))then begin d2:=30; m2:=m1-1; g2:=g1; end
else if ((m1 in [2,4,6,8,9,11]) and(d1=1))then begin d2:=31; m2:=m1-1; g2:=g1; end
else if(m1=3)and (d1=1) then begin if p then d2:=29 else d2:=28; m2:=m1-1; g2:=g1; end
else begin d2:=d1-1; m2:=m1; g2:=g1; end;writeln('Предыдущая дата:');if d2<10 then write('0',d2,'.')else write(d2,'.');if m2<10 then write('0',m2,'.')else write(m2,'.');write(g2);end;end.
var s:string; d1,m1,g1,d2,m2,g2,t,c:integer; p:boolean; k:byte;begin
k:=0;
writeln('Введите дату в формате дд.мм.гг');readln(s); val(copy(s,7,2),t,c);{преобразуем год в число}if (c<>0)or(t<0) then k:=1 else g1:=t;{определим високосный год или нет}if (((g1+2000) mod 100<>0)and((g1+2000) mod 4=0))or((g1+2000) mod 400=0) then p:=trueelse p:=false;
val(copy(s,4,2),t,c);if (c<>0)or not(t in [1..12]) then k:=1 else m1:=t;
val(copy(s,1,2),t,c);if (c<>0)or((m1 in [1,3,5,7,8,10,12])and not(t in [1..31])) or((m1 in [4,6,9,11])and not(t in [1..30])) or(p and(m1=2)and not(t in [1..29])) or(not p and(m1=2)and not(t in [1..28]))then k:=1 else d1:=t;if k=1 thenbeginwriteln('Дата введена неверно!');endelsebeginif(m1=1)and(d1=1)then begin d2:=31; m2:=12; g2:=g1-1; end
else if ((m1 in [5,7,10,12]) and(d1=1))then begin d2:=30; m2:=m1-1; g2:=g1; end
else if ((m1 in [2,4,6,8,9,11]) and(d1=1))then begin d2:=31; m2:=m1-1; g2:=g1; end
else if(m1=3)and (d1=1) then begin if p then d2:=29 else d2:=28; m2:=m1-1; g2:=g1; end
else begin d2:=d1-1; m2:=m1; g2:=g1; end;writeln('Предыдущая дата:');if d2<10 then write('0',d2,'.')else write(d2,'.');if m2<10 then write('0',m2,'.')else write(m2,'.');write(g2);end;end.