(c++程序设计)假设inta=4,b=6,则表达式(a==b)?1:0的值是什么?多谢!

来源:百度知道 编辑:UC知道 时间:2024/05/17 19:17:42

inta=4,b=6;
(a==b)?1:0
是个条件运算符号
如果a==b 取1
如果a!=b 取0

所以值是0

a==b不成立,所以应该是冒号后面的值,0。

0

a,b相等时为1,不相等时为0

0

验证程序:
#include <iostream.h>
void main()
{int a=4,b=5;
cout<<((a==b)?1:0)<<endl;
}