编一个输入年月日,输出该年第几天的程序,哪错了啊?求教哦!
提示的错误有从case 9那里开始case outside of switch in function main;还有 x m is assigned a value which is never used in function main;
#include <stdio.h>
int main()
{
int yea,mon,day,m,x;
scanf("%d.%d.%d",&yea,&mon,&day);
if((yea%4==0&&yea%100!=0)||yea%400==0)
x=1;
else
x=0;
switch (mon)
{
case 1:
{
m=day;
break;
}
case 2:
{
m=day+31;
break;
}
case 3:
{
m=day+31+29;
break;
}
case 4:
{
m=day+31+29+31;
break;
}
case 5:
{
m=day+31+29+31+30;
break;
}
case 6:
{
m=day+31+29+31+30+31;
break;
}
case 7:
{
m=day+31+29+31+30+31+30;
break;
}
case 8:
m=day+31+29+31+30+31+30+31;
break;
}
case 9 :
{
m=day+31+29+31+30+31+30+31+31;
break;
}
case 10:
{
m=day+31+29+31+30+31+30+31+31+30;
break;
}
case 11:
{
m=day+31+29+31+30+31+30+31+31+30+31;
break;
}
case 12:
{
m=day+31+29+31+30+31+30+31+31+30+31+30;
break;
}
}
if(x==1||(x==0&&m<3))
m=m;
else
m=m--;
printf("%d",m);
return 0;
}