在vs上可以运行但是这里是错误为啥
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2008;
int month = 8;
int day = 8;
/*
* 请使用switch语句,if...else语句完成本题
* 如有想看小编思路的,可以点击左侧任务中的“不会了怎么办”
* 小编还是希望大家独立完成哦~
*/
int m, sum;
if ((year % 400 == 0) || (year % 4 == 0) && (year % 100 != 0)) {
m = 29;
}
else {
m = 28;
}
switch (month) {
case 1: sum = day; break;
case 2: sum = day + m; break;
case 3: sum = day + m + 31; break;
case 4: sum = day + m + 31 + 30; break;
case 5: sum = day + m + 31 + 30 + 31; break;
case 6: sum = day + m + 31 + 30 + 31 + 30; break;
case 7: sum = day + m + 31 + 30 + 31 + 30 + 31; break;
case 8: sum = day + m + 31 + 30 + 31 + 30 + 31 + 31; break;
case 9: sum = day + m + 31 + 30 + 31 + 30 + 31 + 31 + 30; break;
case 10: sum = day + m + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; break;
case 11: sum = day + m + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; break;
case 12: sum = day + m + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31; break;
default: printf("一年有十二个月");
}
printf("计算%d年%d月%d日这一天,是该年中的第%d天", year, month, day, sum);
getchar();
getchar();
return 0;
}