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

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

運行兩次,倒數第三個位置沒變,結果卻變了?

#include <stdio.h>

int main()

{

? ? double money =12? ? ? ;?

? ? double cost =11.5? ? ? ?;??

? ? printf("小編能不能打車回家呢:");?

? ? printf("%c\n",money>=cost?'y':'n');

? ? printf("%c\n",(money>=cost)?'y':'n');

? ??

? ? printf("%c\n",(money>cost)||(money=cost)?'y':'n');

? ? printf("%c\n",(money=cost)||(money>cost)?'y':'n');

? ? printf("%c\n",((money>cost)||(money=cost))?'y':'n');

? ??

? ? printf("%c\n",(money>cost)&&(money=cost)?'y':'n');

? ? printf("%c\n",(money=cost)&&(money>cost)?'y':'n');

? ? printf("%c\n",((money>cost)&&(money=cost))?'y':'n');

? ??


? ??

? ??

? ? return 0;

}

#include <stdio.h>

int main()

{

? ? double money =12? ? ? ;?

? ? double cost =11.5? ? ? ?;??

? ? printf("小編能不能打車回家呢:");?

? ? printf("%c\n",money>=cost?'y':'n');

? ? printf("%c\n",(money>=cost)?'y':'n');

? ??

? ? printf("%c\n",(money>cost)||(money=cost)?'y':'n');

? ? printf("%c\n",((money>cost)||(money=cost))?'y':'n');

? ??

? ? printf("%c\n",(money>cost)&&(money=cost)?'y':'n');

? ? printf("%c\n",(money=cost)&&(money>cost)?'y':'n');

? ? printf("%c\n",((money>cost)&&(money=cost))?'y':'n');

? ??


? ??

? ??

? ? return 0;

}


正在回答

2 回答

復制上半部分,把格式改標準,刪除第11行會改變倒數第三行的打印結果。好恐怖,不是n了。刪除第10和第12都沒事。

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

(money>cost)&&(money=cost)

'&&'意思是前后條件都要滿足,所以原因就很簡單了

1 回復 有任何疑惑可以回復我~
#1

weixin_慕絲3003608

||是“或”,是只要有一個滿足條件就可以了
2021-07-21 回復 有任何疑惑可以回復我~
#2

寶慕林9803269 提問者

這是倒數第三行\n: printf("%c\n",(money>cost)&&(money=cost)?'y':'n'); 問題中下面int main()運行結果倒數第三個是y。 上面的int main()運行結果倒數第三個是n。 我的問題是: printf("%c\n",(money>cost)&&(money=cost)?'y':'n');這個運行結果為什么不確定。
2021-07-22 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

運行兩次,倒數第三個位置沒變,結果卻變了?

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

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

幫助反饋 APP下載

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

公眾號

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