#include <stdio.h> int main() { /* 定义需要计算的日期 */ int year = 2008; int month = 8; int day = 8; int sumDay = 0; /* do { month--; switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: sumDay += 31; break; case 2: if(year %4 == 0) { sumDay += 28; } else { sumDay += 27; } break; default: sumDay += 30; break; } printf("月份%d\n",month); printf("%d\n",sumDay); }while(month >= 2); sumDay += day ; printf("%d\n",sumDay); return 0;}
2月闰年有29天,平年28天。你写错了
这个可以输出8月的?
想问一下为什么要加do和那个month––