int year = 2008;
int month = 8;
int day = 8;
int i;
if(year%4==0&&year%100!=0 || year%400==0)
i=1;
else
i=0;
switch(month)
{
case 12: day += 30;
case 11: day += 31;
case 10: day += 30;
case 9: day += 31;
case 8: day += 31;
case 7: day+= 30;
case 6:day += 31;
case 5: day += 30;
case 4: day += 31;
case 3: day == day+28+i;
case 2: day += 31;
break;
}
printf("%d年%d月8日是该年第%d天",year,month,day);
return 0;
}
为什么算的答案不对?
case 3: day == day+28+i;这句多了一个'='
为什么答案少了29天?