#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;
}
复制上半部分,把格式改标准,删除第11行会改变倒数第三行的打印结果。好恐怖,不是n了。删除第10和第12都没事。
(money>cost)&&(money=cost)
'&&'意思是前后条件都要满足,所以原因就很简单了