請(qǐng)大佬指教一下,哪有問題
#include <stdio.h>
int main()
{
??? /* 定義需要計(jì)算的日期 */
??? int year = 2008;
??? int month = 8;
??? int day = 8;
??? switch(month)
??? {
???
??? int date=0;
??? int j;
??? case 12:date+=30;
??? case 11:date+=31;
??? case 10:date+=30;
??? case 9:date+=31;
??? case 8:date+=31;
??? case 7:date+=30;
??? case 6:date+=31;
??? case 5:date+=30;
??? case 4:date+=31;
??? case 3:date+=29;
??? case 2:date+=30;
??? case 1:date-=1;break;
???????
??? }
??? if((year%4==0&&year%100!=0)||year%400==0)
???
???
??????? j=0;
??? else
?????? j=1;
???????? date=date+j+day;
??????? printf("2008年8月8日是本年的第%d天",date);
?return 0;
}
2018-09-16
將date,j定義到switch外面,因?yàn)閟witch是直接跳轉(zhuǎn),不執(zhí)行這兩句