friday.pas

来自「Magio牛的usaco源代码」· PAS 代码 · 共 46 行

PAS
46
字号
{
ID:maigoak1
PROG:friday
}

program friday;
const
  monthday:array[1..12]of byte=(3,0,3,2,3,2,3,3,2,3,2,3);
var
  fin,fout:text;
  count:array[0..6]of integer;
  years,year,month,weekday:integer;
function leap(y:integer):boolean;
  begin
    if y mod 100=0 then
      if y mod 400=0 then leap:=true else leap:=false
    else
      if y mod 4=0 then leap:=true else leap:=false;
  end;
begin
  assign(fin,'friday.in');
  reset(fin);
  readln(fin,years);
  close(fin);

  fillchar(count,sizeof(count),0);
  weekday:=6;
  for year:=1900 to 1899+years do
    for month:=1 to 12 do begin
      inc(count[weekday]);
      if month=2 then
        weekday:=weekday+ord(leap(year))
      else
        weekday:=weekday+monthday[month];
      weekday:=weekday mod 7;
    end;

  assign(fout,'friday.out');
  rewrite(fout);
  write(fout,count[6]);
  for weekday:=0 to 5 do
    write(fout,' ',count[weekday]);
  writeln(fout);
  close(fout);
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?