運行兩次,倒數第三個位置沒變,結果卻變了?
#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;
}
2021-07-22
復制上半部分,把格式改標準,刪除第11行會改變倒數第三行的打印結果。好恐怖,不是n了。刪除第10和第12都沒事。
2021-07-21
(money>cost)&&(money=cost)
'&&'意思是前后條件都要滿足,所以原因就很簡單了