main()
{
int y,m,d,w,c,i=1;
printf("year "); scanf("%d",&y);
printf("month "); scanf("%d",&m);
printf("day "); scanf("%d",&d);
while(i==1)
{
if ( (y%4!=0&&m>0&&m!=2&&m<13&&d>0&&d<32)
||(y%4!=0&&m==2&&d>0&&d<29)
||(y%4==0&&m>0&&m!=2&&m<13&&d>0&&d<32)
||(y%4==0&&m==2&&d>0&&d<30) )
{
c=y/100;
y=y-100*c;
if (m<3)
{
y=y-1;
m=m+12;
}
w=y+y/4;
w=w+c/4;
w=w-2*c+26*(m+1)/10+d-1;
w=w%7;
switch(w)
{
case 0:printf("Sunday");break;
case 1:printf("Monday");break;
case 2:printf("Tuesday");break;
case 3:printf("Wednesday");break;
case 4:printf("Thursday");break;
case 5:printf("Friday");break;
default:printf("Saturday");
}
}
else
{
printf("error \n \n");
}
printf("\n\nyear "); scanf("%d",&y);
printf("month "); scanf("%d",&m);
printf("day "); scanf("%d",&d);
}
getch();
}
刚才做的程序