void main()
{
int y,m,d;
int sum=0;
int flog;//标识是否是闰年
printf("请输入年月日(yyyy-mm-dd)/n");
scanf("%4d-%2d-%2d",&y,&m,&d);
if(( y%4==0 && y%100!=0 ) || y%400==0)
flog=1;
else
flog=0;
while((y<0)||(m>12||m<0)||(d<0||d>31)||((m%2==0)&&(d==31))||((flog==1)&&(m==2)&&(d>28)))
{
printf("input errro!/n");
printf("请输入年月日(yyyy-mm-dd)/n");
scanf("%4d-%2d-%2d",&y,&m,&d);
}
switch (m-1)
{
case 12: sum+=31;
case 11: sum+=30;
case 10: sum+=31;
case 9: sum+=30;
case 8: sum+=31;
case 7: sum+=31;
case 6: sum+=30;
case 5: sum+=31;
case 4: sum+=30;
case 3: sum+=31;
case 2:
if(flog==1) //这里改一下
sum+=28;
else
sum+=30;
case 1: sum+=31;break; //这里加上一个break语句
default:printf("非法月份/n");
break;
}
sum=sum+d;
if(flog==1)
printf("%d is leap year!/n",y);
printf("这一天是这年的第%d天",sum);
}