第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

有沒有大哥幫忙看一下哪里不對

判斷大小月

請用程序?qū)崿F(xiàn): 輸入一個(gè)表示月份的整數(shù),判斷它是大月還是小月。如果是大月,輸出solar month;如果是小月,輸出lunar month; 如果輸入數(shù)據(jù)不合法, 則輸出error。

注意: 如果一個(gè)月有31天則被稱為大月;如果一個(gè)月有30天則被稱為小月,2月既不是大月也不是小月,在本題中,將2月劃分到小月。

#include <stdio.h>

int main () {
??? // TODO 請?jiān)诖颂幘帉懘a,完成題目要求
??? int month=2;
??? if(month==1||3||5||7||8||10||12)
??? {
??????? printf("solar month");
??? }
??????? else if(month==2||4||6||9||11)
??????? {
??????????? printf("lunar month");
??????? }
??? else
??? {
??????? printf("error");
??? }
??? return 0;
}


正在回答

2 回答

int main(void) {?

int month=2;

? ? if((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12))

? ? {

? ? ? ? printf("solar month\n");

? ? }

? ? else if((month==2)||(month==4)||(month==6)||(month==9)||(month==11))

? ? ? ? {

? ? ? ? ? ? printf("lunar month\n");

? ? ? ? }

? ? else

? ? {

? ? ? ? printf("error\n");

? ? }

? ? return 0;

}


0 回復(fù) 有任何疑惑可以回復(fù)我~

在你的if(month==1||3||5||7||8||10||12) 代碼中,(程序認(rèn)為你的意思是:2=1,或者2=3,或2=5....)

然后,month=2 為"True",就直接輸出"solar month",不再執(zhí)行下面的語句。

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

小龍佩奇

所以要改成: if((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12)) { printf("solar month\n"); } else if((month==2)||(month==4)||(month==6)||(month==9)||(month==11)) { printf("lunar month\n");
2020-03-13 回復(fù) 有任何疑惑可以回復(fù)我~
#2

北淵 提問者

感謝!講得很清楚
2020-03-13 回復(fù) 有任何疑惑可以回復(fù)我~
#3

小龍佩奇 回復(fù) 北淵 提問者

也可能是因?yàn)閙onth==1||3||5||7||8||10||12在C中計(jì)算出一個(gè)為"True"的邏輯值。 我是小白,如果回答錯(cuò)了請?jiān)彛。?/div>
2020-03-13 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

有沒有大哥幫忙看一下哪里不對

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號