運(yùn)行兩次,倒數(shù)第三個(gè)位置沒(méi)變,結(jié)果卻變了?
#include <stdio.h>
int main()
{
? ? double money =12? ? ? ;?
? ? double cost =11.5? ? ? ?;??
? ? printf("小編能不能打車(chē)回家呢:");?
? ? 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("小編能不能打車(chē)回家呢:");?
? ? 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;
}
2021-07-22
復(fù)制上半部分,把格式改標(biāo)準(zhǔn),刪除第11行會(huì)改變倒數(shù)第三行的打印結(jié)果。好恐怖,不是n了。刪除第10和第12都沒(méi)事。
2021-07-21
(money>cost)&&(money=cost)
'&&'意思是前后條件都要滿足,所以原因就很簡(jiǎn)單了