输入某年某月某日,判断这一天是这一年的第几天,,以下的程序这样编对吗?我不知道错在哪额
输入某年某月某日,判断这一天是这一年的第几天,,以下的程序这样编对吗 #include<stdio.h>void main()
{
int day,month,year,sum,leap;
printf("\nplease input year,month,day\n");
scanf("%d,%d,%d",&year,&month,&day);
sum=0;
switch(month)
{
case 12:sum=sum+30;
case 11:sum=sum+31;
case 10:sum=sum+30;
case 9:sum=sum+31;
case 8:sum=sum+30;
case 7:sum=sum+31;
case 6:sum=sum+30;
case 5:sum=sum+31;
case 4:sum=sum+30;
case 3:sum=sum+28;
case 2:sum=sum+31;
case 1:sum=sum+day;break;
default:printf("data error");break;
}
sum=sum+day;
if(year%400==0||(year%4==0&&year%100!=0))
leap=1;
else
leap=0;
if(leap==1&&month>2)
sum++;
printf("it is the %dth day.",sum);}
请大神们帮我看看,哪错了啊
谢谢!