&&与||小提示
&&
&&运算符从左自由依次判断 ,如果判断有一个为假则停止判断
||
同理如果判断有一个为真则停止判断
例
#include<iostream>
using namespace std;
int main()
{
int a=0,b=1,c;
c = (a != b) || (++a == b++);
cout<<a<<" "<<b<<endl;
return 0;
}
输出为0 1因为前面一个为真,直接退出判断
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment