//输入格式例如:2016年1月1号,,应写为2016/1/1
#include"stdio.h"
int main()
{
int year,month,day,sumday=0;
scanf("%d/%d/%d",&year,&month,&day);//个位数的前面不加0,例如8月写成8,而不是08。
switch(month)
{
case 1:{printf("sumday=%d",sumday+day);break;}
sumday+=31;
case 2: {printf("sumday=%d",sumday+day);break;}
if((year%100!=0&&year%4==0)||year%400==0)
{
sumday=sumday+29;
}
else
{
sumday=sumday+28;
}
case 3:{printf("sumday=%d",sumday+day);break;}
sumday=sumday+31;
case 4:{printf("sumday=%d",sumday+day);break;}
sumday+=30;
case 5:{printf("sumday=%d",sumday+day);break;}
sumday+=31;
case 6:{printf("sumday=%d",sumday+day);break;}
sumday+=30;
case 7:{printf("sumday=%d",sumday+day);break;}
sumday+=31;
case 8:{printf("sumday=%d",sumday+day);break;}
sumday+=31;
case 9:{printf("sumday=%d",sumday+day);break;}
sumday+=30;
case 10:{printf("sumday=%d",sumday+day);break;}
sumday+=31;
case 11:{printf("sumday=%d",sumday+day);break;}
sumday+=30;
case 12:{printf("sumday=%d",sumday+day);break;}
default:printf("error\n"); break;
}
return 0;
}
//为什么输入2016/12/31,结果显示确实“sum=31”
心有猛虎_细嗅蔷薇
慕的地6079101
qq_深猫_04306026