#include <stdio.h> int main() { int year = 2008; int month = 8; int day = 8; int sum; switch(month) { case1:sum=0;break; case3: if(year%400==0||(year%4==0&&year%400!=0)) { sum+=29; } else { sum+=28; } break; case2:sum+=31; case4:sum+=30; case5:sum+=31; case6:sum+=30 case7:sum+=31; case8:sum+=31; case9:sum+=30; case10:sum+=31; case11:sum+=30; case12:sum+=31;break; } sum=sum+day; printf("%d年%d月%d日是该年的第%d天",year,month,day,sum); return 0; }
case 和常量表达式之间要有空格,你的没有,所以根本没有进到 switch 里
楼上正解