日期肯定合法,绝不会出现类似-23年13月52日的情况
已知1980年1月1日是星期二。
#include <stdio.h>
int main()
{
int y=0,m=0,d=0,i=0,s=0,z=0,er=0;
scanf("%d %d %d",&y,&m,&d);
for(i=1980;i<y;i++)
{
if((i%400==0)||((i%4==0)&&(i%100!=0)))
s+=366;
else
s+=365;
}
if((y%400==0)||((y%4==0)&&(y%100!=0)))
er=29;
else
er=28;
switch(m)
{
case 1:z=d;break;
case 2:z=31+d;break;
case 3:z=31+er+d;break;
case 4:z=31+er+31+d;break;
case 5:z=31+er+31+30+d;break;
case 6:z=31+er+31+30+31+d;break;
case 7:z=31+er+31+30+31+30+d;break;
case 8:z=31+er+31+30+31+30+31+d;break;
case 9:z=31+er+31+30+31+30+31+31+d;break;
case 10:z=31+er+31+30+31+30+31+31+30+d;break;
case 11:z=31+er+31+30+31+30+31+31+30+31+d;break;
case 12:z=31+er+31+30+31+30+31+31+30+31+30+d;break;
}
s+=z;
printf("%d\n",s%7+1);
return 0;
}
/*
var y,m,d,i,s,z,er:longint;
begin
readln(y,m,d);
for i:=1980 to y-1 do
if (i mod 4=0) and (i mod 100<>0) or (i mod 400=0) then s:=s+366
else s:=s+365;
if (y mod 4=0) and (y mod 100<>0) or (y mod 400=0) then er:=29
else er:=28;
case m of
1:z:=d;
2:z:=31+d;
3:z:=er+31+d;
4:z:=er+62+d;
5:z:=er+92+d;
6:z:=er+123+d;
7:z:=er+153+d;
8:z:=er+184+d;
9:z:=er+215+d;
10:z:=er+245+d;
11:z:=er+276+d;
12:z:=er+306+d;
end;
s:=s+z;
writeln(s mod 7+1);
end.
*/