|
|
вернуться в форумWA#6 ?? I can't understand !! Here is my code : {$M 16777216} Program P1201_Which_day_is_it; {$APPTYPE CONSOLE} Var Days:array [1600..2400] of byte; fday,day,sum,month:byte; year:word; i,j,k,h,d,code:integer; s,t:string; Calendar:array[1..7] of string; {-----------------------------------------------------------} Procedure Init; Begin Days[1600]:=2; i:=1601; While i<=year do Begin days[i]:=days[i-1]; if (i-1) mod 4 =0 then inc(days[i]); if i-1=1918 then inc(days[i]); inc(days[i]); if days[i]>7 then days[i]:=days[i] mod 7; inc(i); end; End; {-----------------------------------------------------------} Begin {$IFNDEF ONLINE_JUDGE} Assign(input,'Input.txt'); Reset(input); Assign(output,'Output.txt'); Rewrite(output); {$ENDIF} Readln(input,day,month,year); init; fday:=days[year]; For i:=1 to month-1 do Begin if (i=1)or(i=3)or(i=5)or(i=7)or(i=8)or(i=10) then inc(fday,3); if (i=2) then if year mod 4 = 0 then inc(fday,1); if (i=4)or(i=6)or(i=9)or(i=11)or(i=12) then inc(fday,2); End; if (month=1)or(month=3)or(month=5)or(month=7)or(month=8)or(month=10) then sum:=31; if (month=2) then if (year mod 4=0) then sum:=29 else sum:=28; if (month=4)or(month=6)or(month=11)or(month=12) then sum:=30; Calendar[7]:='sun'; Calendar[1]:='mon'; Calendar[2]:='tue'; Calendar[3]:='wed'; Calendar[4]:='thu'; Calendar[5]:='fri'; Calendar[6]:='sat'; if fday>7 then fday:=fday mod 7; for i:=fday-1 downto 1 do Calendar[i]:=Calendar[i]+' '; k:=fday; for i:=1 to sum do begin if i=day then s:=']' else s:=' '; str(i,t); if length(t)=1 then t:=' '+t; s:=t+s; if i=day then s:='['+s; while length(s)<5 do s:=' '+s; Calendar[k]:=Calendar[k]+s; if k=7 then k:=1 else inc(k); end; For i:=1 to 7 do Begin While Calendar[i][length(calendar[i])]=' ' do delete(Calendar[i],Length(calendar[i]),1); writeln(output,Calendar[i]); End; {$IFNDEF ONLINE_JUDGE} Close(input); Close(output); {$ENDIF} End. My code have WA#6, but I think it alright !! Re: WA#6 Послано melkiy 27 апр 2009 01:43 No 1918 or 1752 calendar corrections must be taken into account. Do just what is asked in the condition. |
|
|