如何计算某天是星期几
#include <stdio.h>int main()
{
int i,j,a,b, year,month,day;
long int s,t,total;
char week;
scanf("%d %d %d",&year,&month,&day);
for(i=0;i<=year-1;i++)
{
if((i%4==0 && i%100!=0)||(i%400==0))
j=366;
else
{
j=365;
}
s=((i+1)-i)*j;
}
for(a=0;a<=month-1;a++)
{if(i%4!=0)
{
if(a=2)b=28;
else
{
if(a=1||3||5||7||8||10)
b=31;
else
b=30;
}
else
{if((i%4==0 && i%100!=0)||(i%400==0))
{
if(a=2)b=29;
}
else
{
if(a=1||3||5||7||8||10)
b=31;
else
b=30;
}
}
t=((a+1)-a)*b;
}
}
total=(((i+1)-i)*j)+(((a+1)-a)*b)+day;
week=total%7;
if(week=1)
printf("Monday%c\n");
if(week=2)
printf("Tuesday%c\n");
if(week=3)
printf("Wednesday%c\n");
if(week=4)
printf("Thursday%c\n");
if(week=5)
printf("Friday%c\n");
if(week=6)
printf("Saturday%c\n");
if(week=7)
printf("Sunday%c\n");
return 0;
}