Vladimir_S |
29.05.2011 21:35 |
Цитата:
Сообщение от Владиславик
(Сообщение 528841)
помогите пожалуйста, а то у меня завал...
|
Да пожалуйста.
Там сначала вводится тип года - обычный, високосный, потом отсчет дня.
Код:
CONST
Month_Name:Array[1..12] of String=('January','February','March','April',
'May','June','July','August',
'September','October','November','December');
Days_in_Months_not_bis:Array[1..12] of Byte=(31,28,31,30,31,30,
31,31,30,31,30,31);
Days_in_Months_bis:Array[1..12] of Byte=(31,29,31,30,31,30,
31,31,30,31,30,31);
VAR
Year_Type,Month:Byte;
i,j,N,Days:Integer;
BEGIN
Write('Year_Type(not bis - 1, bis - 2): ');
ReadLn(Year_Type);
Write('Day number: ');
ReadLn(N);
Days:=0;
Month:=0;
If ((Year_Type=1) and (N=365)) or ((Year_Type=2) and (N=366)) then
Writeln('31 of December')
else
Begin
Repeat
Inc(Month);
If Year_Type=1 then
Inc(Days,Days_in_Months_not_bis[Month])
else
Inc(Days,Days_in_Months_bis[Month]);
Until Days>N;
If Year_Type=1 then
Dec(Days,Days_in_Months_not_bis[Month])
else
Dec(Days,Days_in_Months_bis[Month]);
Writeln(N-Days:2,' of '+Month_Name[Month]);
End;
Readln
END.
|