判断某年某月某日是星期几.
int j_rn(int y){
if(y%4==0&&y%100!=0||y%400==0)
return 1;
else
return 0;
}
main()
{
int y,m,d,s=28,n,num;
printf("\nPlease input year,month and date:");
scanf("%d %d %d",&y,&m,&d);
if(j_rn(y))
s=29;
switch(m)
{
case 1:n=d;break;
case 2:n=31+d;break;
case 3:n=31+s+d;break;
case 4:n=31+s+31+d;break;
case 5:n=31+s+31+30+d;break;
case 6:n=31+s+31+30+31+d;break;
case 7:n=31+s+31+30+31+30+d;break;
case 8:n=31+s+31+30+31+30+31+d;break;
case 9:n=31+s+31+30+31+30+31+31+d;break;
case 10:n=31+s+31+30+31+30+31+31+30+d;break;
case 11:n=31+s+31+30+31+30+31+31+30+31+d;break;
case 12:n=31+s+31+30+31+30+31+31+30+31+30+d;
}
num=(y-1)+(y-1)/4-(y-1)/100+(y-1)/400+n;
printf("%d\n",num%7);
getch();
}