作用:用于表达式的比较,并返回一个真值或者假值
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
using namespace std;
int main()
{
//==
int a = 10;
int b = 20; //变量a重新赋值为100
//==
cout << (a==b) << endl;
//!=
cout << (a != b) << endl;
//>
cout << (a > b) << endl;
//<
cout << (a < b) << endl;
//>=
cout << (a >= b) << endl;
//<=
cout << (a <= b) << endl;
system("pause");
return 0;
}
运行结果:
0
1
0
1
0
1
注:1表示真,0表示假