亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

求助,error看不懂......

#include <stdio.h>

int main()?

{?

? ? /* 定義需要計算的日期 */

? ? int year = 2008;

? ? int month = 8;

? ? int day = 8;

? ? int today=0;

? ? /*

? ? ?* 請使用switch語句,if...else語句完成本題

? ? ?* 如有想看小編思路的,可以點擊左側任務中的“不會了怎么辦”

? ? ?* 小編還是希望大家獨立完成哦~

? ? ?*/

? ? if(year%4==0)

? ? {

? ? ? ? switch(month)

? ? ? ? {

? ? ? ? ? ? case 12:today+=30;

? ? ? ? ? ? case 11:today+=29;

? ? ? ? ? ? case 10:today+=30;

? ? ? ? ? ? case 9:today+=29;

? ? ? ? ? ? case 8:today+=30;

? ? ? ? ? ? case 7:today+=30;

? ? ? ? ? ? case 6:today+=29;

? ? ? ? ? ? case 5:today+=30;

? ? ? ? ? ? case 4:today+=29;

? ? ? ? ? ? case 3:today+=30;

? ? ? ? ? ? case 2:today+=29;

? ? ? ? ? ? case 1:today+=day;

? ? ? ? ? ? break;

? ? ? ? printf("今日是%d年的第%d天",year,today);

? ? ? ? }

? ? ? ? else

? ? ? ? {

? ? ? ? ? ? switch(month)

? ? ? ? ? ? {

? ? ? ? ? ? case 12:today+=30;

? ? ? ? ? ? case 11:today+=29;

? ? ? ? ? ? case 10:today+=30;

? ? ? ? ? ? case 9:today+=29;

? ? ? ? ? ? case 8:today+=30;

? ? ? ? ? ? case 7:today+=30;

? ? ? ? ? ? case 6:today+=29;

? ? ? ? ? ? case 5:today+=30;

? ? ? ? ? ? case 4:today+=29;

? ? ? ? ? ? case 3:today+=30;

? ? ? ? ? ? case 2:today+=28;

? ? ? ? ? ? case 1:today+=day;

? ? ? ? ? ? break;

? ? ? ? printf("今日是%d年的第%d天",year,today);

? ? ? ? ? ? }

? ? ? ? }

? ? }

? ??

? ? #include <stdio.h>

int main()?

{?

? ? /* 定義需要計算的日期 */

? ? int year = 2008;

? ? int month = 8;

? ? int day = 8;

? ? /*

? ? ?* 請使用switch語句,if...else語句完成本題

? ? ?* 如有想看小編思路的,可以點擊左側任務中的“不會了怎么辦”

? ? ?* 小編還是希望大家獨立完成哦~

? ? ?*/

? ??

? ??

? ??

? ??

? ??

? ??









return 0;

}


正在回答

2 回答

你改成這樣比較好。

#include <stdio.h>

int main()?

{

? ? int year = 2008;

? ? int month = 8;

? ? int day = 8;

? ? int today=0,r=0,yue=month;

? ? if((year%4==0&&year%100!=0)||year%400==0)

? ? r=1;

? ? switch(yue-1)

? ? {

? ? ? ? case 11:today+=30;

? ? ? ? case 10:today+=31;

? ? ? ? case 9:today+=30;

? ? ? ? case 8:today+=31;

? ? ? ? case 7:today+=31;

? ? ? ? case 6:today+=30;

? ? ? ? case 5:today+=31;

? ? ? ? case 4:today+=30;

? ? ? ? case 3:today+=31;

? ? ? ? case 2:today+=28+r;

? ? ? ? case 1:today+=31;

? ? ? ? case 0:today+=day;

? ? ? ? break;

? ? }

? ? ? ? printf("%d年%d月%d日是該年的第%d天",year,month,day,today);

? ? return 0;?

}


0 回復 有任何疑惑可以回復我~

if少了個括號,return 0;沒寫 還有程序的算法部分是錯的

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
C語言入門
  • 參與學習       926904    人
  • 解答問題       21533    個

C語言入門視頻教程,帶你進入編程世界的必修課-C語言

進入課程

求助,error看不懂......

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號