Operator | Name | Example |
---|---|---|
== | 等于 Equal to | x == y |
!= | 不等于Not equal | x != y |
> | 大于Greater than | x > y |
< | < Less than | x < y |
>= | 大于等于Greater than or equal to | x >= y |
<= | 小于等于Less than or equal to | x <= y |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <iostream> using namespace std; int main() { int a; cout<<"please input a number:"; cin>>a; if(a==10)cout<<"I am equal to ten"<<endl; if(a!=10)cout<<"I am not equal to ten"<<endl; if(a>10)cout<<"I am greater than ten"<<endl; if(a<10)cout<<"I am less than tem"<<endl; if(a>=10)cout<<"I am Greater than or equal to ten"<<endl; if(a<=10)cout<<"I am Less than or equal to ten"<<endl; return 0; } |