#include
long int ri(long int n,long int y,long int r);
long int rui(long int n);
long int main()
{ long int n,y,r;
printf("输入年 月 日");
scanf("%d%d%d",&n,&y,&r);
switch (ri(n,y,r))
{
case 0:printf("星期天\n");break;
case 1:printf("星期一\n");break;
case 2:printf("星期二\n");break;
case 3:printf("星期三\n");break;
case 4:printf("星期四\n");break;
case 5:printf("星期五\n");break;
case 6:printf("星期六\n");break;
}
return 0;
}
long int ri(long int n,long int y,long int r)
{
long int rui(long int n);
long int t,i,a=0,b[12]={31,28,31,30,31,30,31,31,30,31,30,31},j=0;
if(n<1900)
{
for (i=1899;i>=n;i--)
a=rui (i)+a;
for(i=0;i
if (rui(n))
j = j+1;
t=(1900-n)*365-a-j-r;
t=t%7;
t = (7-t)%7;
}
else
{
for (i=1900;i
for(i=0;i
if (rui(n))
j = j+1;
t=(n-1900)*365+a+j+r;
t=t%7;
}
return t;
}
long int rui(long int y)
{
if((y%4==0)&&(y%100!=0)||(y%400==0))
return 1;
else
return 0;
}
试了,没问题。
有什么问题?正常运行