久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

比較運(yùn)算符的數(shù)學(xué)式鏈接-如“if((5<j<=1))&qu

Math-like chaining of the comparison operator - as in, quot;if ( (5lt;jlt;=1) )quot;(比較運(yùn)算符的數(shù)學(xué)式鏈接-如“if((5<j<=1)))
本文介紹了比較運(yùn)算符的數(shù)學(xué)式鏈接-如“if((5<j<=1))"的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

int j=42;
if( (5<j<=1) ) {
    printf("yes");
} else {
    printf("no");
}

輸出:

yes

為什么輸出yes?
條件不是只對(duì)了一半嗎?

Why does it output yes?
Isn't the condition only half true?

推薦答案

C 不理解類似數(shù)學(xué)的語(yǔ)法,所以

C does not understand math-like syntax, so

if(1<j<=5)

沒有按照您的預(yù)期和想要的方式進(jìn)行解釋;應(yīng)該是

is not interpreted as you expect and want; it should be

if (1 < j && j <= 5)

或類似的.

正如在其他答案中所解釋的,表達(dá)式的計(jì)算方式為

As explained in other answers, the expression is evaluated as

 ((1 < j) <= 5)

 =>  ("true" <= 5)

 =>  "true"

其中true"(布爾值)隱式轉(zhuǎn)換為 1,如 explaneid,例如此處,也參考了標(biāo)準(zhǔn),這解釋了為什么true"必須是less"比" 5(盡管在 C 中談?wù)搹?bool 到 int 的隱式轉(zhuǎn)換"可能并不完全正確)

where "true" (boolean value) is implicitly converted to 1, as explaneid e.g. here, with references to standards too, and this explain why "true" has to be "less than" 5 (though in C might not be totally correct to speak about "implicit conversion from bool to int")

這篇關(guān)于比較運(yùn)算符的數(shù)學(xué)式鏈接-如“if((5<j<=1))"的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

What do compilers do with compile-time branching?(編譯器如何處理編譯時(shí)分支?)
Can I use if (pointer) instead of if (pointer != NULL)?(我可以使用 if (pointer) 而不是 if (pointer != NULL) 嗎?)
Checking for NULL pointer in C/C++(在 C/C++ 中檢查空指針)
Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之間的區(qū)別與“if())
C++, variable declaration in #39;if#39; expression(C++,if 表達(dá)式中的變量聲明)
if (cin gt;gt; x) - Why can you use that condition?(if (cin x) - 為什么你可以使用那個(gè)條件?)
主站蜘蛛池模板: 欧美啪啪网站 | 麻豆一区二区三区 | 亚洲免费在线视频 | 国语对白永久免费 | 国产欧美日韩一区 | 就要干就要操 | 久久精品欧美 | 亚洲精品a| 久久伊人网站 | 伊人国产女 | 日韩网站免费观看 | www.久久久久久 | 日韩少妇av| 两性免费视频 | 大尺度做爰呻吟舌吻网站 | 国产激情网站 | 国产视频网 | 婷婷在线视频 | 欧美伊人久久 | 中文在线字幕免费观 | 糖心vlog精品一区二区 | 亚洲免费av在线 | 日本中文字幕在线播放 | 久久狠 | 成人午夜激情视频 | 欧美视频一二三区 | 国产精品第五页 | 日日夜夜狠狠 | 一区免费视频 | 精品视频久久 | 午夜国产在线观看 | 国产盗摄视频 | 成年免费视频黄网站在线观看 | 中文字幕在线免费看 | 午夜精品久久久久久久久久蜜桃 | 免费一看一级毛片 | 国产综合亚洲精品一区二 | 91在| 日韩欧美国产综合 | 一级黄色大片 | 999精品在线 |