#include <stdio.h>
int main()
{
int year = 2008, month = 8, day = 8;
int sum = 0;
switch(month-1)
{
case 1:
sum += 31;
case 2:
if(year%4 == 0 || year%100 != 0 && year%400 == 0 )
sum +=29;
else
sum +=28;
case 3:
sum += 31;
case 4:
sum += 30;
case 5:
sum += 31;
break;
case 6:
sum += 30;
case 7:
sum += 31;
case 8:
sum += 31;
case 9:
sum += 30;
case 10:
sum += 31;
case 11:
sum += 30;
case 12:
sum += 31;
}
sum = sum + day;
printf("%d\n",sum);
return 0;
}
老师我这个结果不对,,找不到哪里错了,,拜托帮我纠正,讲解一下。谢谢老师啊!
这个应该倒着排吧 并且 switch(month-1) 不用 减 1