看板 C_and_CPP 關於我們 聯絡資訊
我在使用過code::block發現很好用 所以漸漸的靶Dev C++給扔了 可是最近老師出的一題作業 我寫出來後 用code::block卻無法編譯成功 DEV C++卻可以 不知道問題出在哪 我不想放棄使用code::block啊~ 大家可以幫我看一下嘛 程式碼如下: #include<stdio.h> typedef enum {January,February,March,April,May,June, July,August,September,October,November,December} month_t; void print_month(month_t month_mmm); int main(void){ month_t month_mmm; month_mmm=January; int year = 2005; while (year != 2011){ for (month_mmm;month_mmm<=December;month_mmm = month_mmm+5){ printf("%d, ",year); print_month(month_mmm); printf("\n");} if( month_mmm >=12){ month_mmm = month_mmm - 12; year = year + 1;} } return 0; } void print_month(month_t month_mmm){ switch (month_mmm){ case January: printf("January"); break; case February: printf("February"); break; case March: printf("March"); break; case April: printf("April"); break; case May: printf("May"); break; case June: printf("June"); break; case July: printf("July"); break; case August: printf("August"); break; case September: printf("September"); break; case October: printf("October"); break; case November: printf("November"); break; case December: printf("December"); break;} } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.125.207.15
chrisdar:... month_mmm = month_t(month_mmm + 5) ... 04/27 00:36
plover:print month 可以用個array of string..這樣就不用switch 04/27 00:40