输入年、月、日表示出星期几!
#include<stdio.h>int main()
{
int year,month,day,d,i,t,s,sum,z;
scanf("%d%d%d",&year,&month,&day);
if((year%4==0&&year%100!=0)||(year%400==0))
{
if(month==1)
sum=0;
else if(month==2)
sum=31;
else if(month==3)
sum=31+29;
else if(month==4)
sum=31+29+31;
else if(month==5)
sum=31+29+31+30;
else if(month==6)
sum=31+29+31+30+31;
else if(month==7)
sum=31+29+31+30+31+30;
else if(month==8)
sum=31+29+31+30+31+30+31;
else if(month==9)
sum=31+29+31+30+31+30+31+31;
else if(month==10)
sum=31+29+31+30+31+30+31+31+30;
else if(month==11)
sum=31+29+31+30+31+30+31+31+30+31;
else if(month==12)
sum=31+29+31+30+31+30+31+31+30+31+30;
d=366;
}
else
{
if(month==1)
sum=0;
else if(month==2)
sum=31;
else if(month==3)
sum=31+28;
else if(month==4)
sum=31+28+31;
else if(month==5)
sum=31+28+31+30;
else if(month==6)
sum=31+28+31+30+31;
else if(month==7)
sum=31+28+31+30+31+30;
else if(month==8)
sum=31+28+31+30+31+30+31;
else if(month==9)
sum=31+28+31+30+31+30+31+31;
else if(month==10)
sum=31+28+31+30+31+30+31+31+30;
else if(month==11)
sum=31+28+31+30+31+30+31+31+30+31;
else if(month==12)
sum=31+28+31+30+31+30+31+31+30+31+30;
d=365;
}
t=sum+day;
while(i<=year)
{
i=i+1;
s=s+d;
}
z=s+t;
if(s%7==0)
printf("星期五");
else if(s%7==1)
printf("星期六");
else if(s%7==2)
printf("星期日");
else if(s%7==3)
printf("星期一");
else if(s%7==4)
printf("星期二");
else if(s%7==5)
printf("星期三");
else if(s%7==6)
printf("星期四");
return 0;
}
各位哥哥姐姐,我是初学者,想请教一下这个程序有什么问题啊?需要怎么改啊?我现在的分不多,见谅见谅哦!