#include <stdio.h>
int main()
{
int year,month,day,sum=0;
printf("请输入你的年 月 日:\n");
scanf("%d%d%d",&year,&month,&day);
switch(month)
{
case2:sum=31;break;
case3:sum=28+31;break;
case4:sum=28+31+30;break;
case5:sum=28+31+30+30;break;
case6:sum=28+31+30+30+31;break;
case7:sum=28+31+30+30+31+30;break;
case8:sum=28+31+30+30+31+30+31;break;
case9:sum=28+31+30+30+31+30+31+31;break;
case10:sum=28+31+30+30+31+30+31+31+30;break;
case11:sum=28+31+30+30+31+30+31+31+30+31;break;
case12:sum=28+31+30+30+31+30+31+31+30+31+31;break;
}
sum=sum+day;
if(year%400==0||(year%4==0&&year%100!=0))
{
if(month>2){
sum++;
}
}
printf("%d\n",sum);
return 0;
}
代码运行没有错误,但运行出来结果有错。