課程
/后端開發(fā)
/C
/C語言入門
為什么當(dāng)case 2: sum=31;不應(yīng)該是28或29嗎
2022-01-16
源自:C語言入門 4-17
正在回答
搜索
復(fù)制
慕正非 提問者
#include<stdio.h>
int main()
{
int year=2008,month=8,day=8;
switch(month-1)
case 12:day+=31;
case 11:day+=30;
case 10:day+=31;
case 9:day+=30;?
case 8:day+=31;
case 7:day+=31;
case 6:day+=30;
case 5:day+=31;
case 4:day+=30;
case 3:day+=31;
case 2:if(year%400==0||year%4==0&&year%400!=0)
day+=29;?
}
else{
day+=28;
case 1:day+=31 ;
? printf("2008年8月8日是該年的第%d天",day);
}return 0;?
舉報(bào)
C語言入門視頻教程,帶你進(jìn)入編程世界的必修課-C語言
1 回答怎么感覺這個(gè)代碼有問題?
4 回答編編,這代碼應(yīng)該有個(gè)小問題
1 回答感覺有問題
1 回答感覺例子有問題
6 回答我覺得這多維數(shù)代碼有問題
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2022-01-17
搜索
復(fù)制
2022-09-01
#include<stdio.h>
int main()
{
int year=2008,month=8,day=8;
switch(month-1)
{
case 12:day+=31;
case 11:day+=30;
case 10:day+=31;
case 9:day+=30;?
case 8:day+=31;
case 7:day+=31;
case 6:day+=30;
case 5:day+=31;
case 4:day+=30;
case 3:day+=31;
case 2:if(year%400==0||year%4==0&&year%400!=0)
{
day+=29;?
}
else{
day+=28;
}
case 1:day+=31 ;
? printf("2008年8月8日是該年的第%d天",day);
}return 0;?
}