运行后出来的是8天,小白不知道错在哪里。
#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; }