課程
/后端開發
/C
/C語言入門
為什么當case 2: sum=31;不應該是28或29嗎
2022-01-16
源自:C語言入門 4-17
正在回答
搜索
復制
慕正非 提問者
#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;?
舉報
C語言入門視頻教程,帶你進入編程世界的必修課-C語言
1 回答怎么感覺這個代碼有問題?
4 回答編編,這代碼應該有個小問題
1 回答感覺有問題
1 回答感覺例子有問題
6 回答我覺得這多維數代碼有問題
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2022-01-17
搜索
復制
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;?
}