恕我懒惰 老师 我觉得答案还要自己累加算 不够智能 我想让计算机算 所以这么做的 但他说我的break不在switch语句中
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2008;
int month = 8;
int day = 8;
int sign;
if(year%4==0)
{
sign=1;
switch(sign)
case 1 : day+=31; if(sign==month) break; sign++;
case 2 : day+=28; if(sign==month) break; sign++;
case 3 : day+=31; if(sign==month) break; sign++;
case 4 : day+=30; if(sign==month) break; sign++;
case 5 : day+=31; if(sign==month) break; sign++;
case 6 : day+=30; if(sign==month) break; sign++;
case 7 : day+=31; if(sign==month) break; sign++;
case 8 : day+=31; if(sign==month) break; sign++;
case 9 : day+=30; if(sign==month) break; sign++;
case 10: day+=31; if(sign==month) break; sign++;
case 11: day+=30; if(sign==month) break; sign++;
case 12: day+=31; if(sign==month) break; sign++;
printf("这是今年的第%d天",day);
}
else
{
sign=1;
switch(sign)
case 1 : day+=31; if(sign==month) break; sign++;
case 2 : day+=29; if(sign==month) break; sign++;
case 3 : day+=31; if(sign==month) break; sign++;
case 4 : day+=30; if(sign==month) break; sign++;
case 5 : day+=31; if(sign==month) break; sign++;
case 6 : day+=30; if(sign==month) break; sign++;
case 7 : day+=31; if(sign==month) break; sign++;
case 8 : day+=31; if(sign==month) break; sign++;
case 9 : day+=30; if(sign==month) break; sign++;
case 10: day+=31; if(sign==month) break; sign++;
case 11: day+=30; if(sign==month) break; sign++;
case 12: day+=31; if(sign==month) break; sign++;
printf("这是今年的第%d天",day);
}
return 0;
}