2
爲什麼我在第三行上得到不同的結果? 輸出結果爲:以相反順序打印表達式時獲得不同結果
1
1
0
1
我不應該收到行號。 3也輸出1
而不是0
?它與其他行具有相同的語法。
#include <iostream>
using namespace std;
int main()
{
int x = -3;
bool a = (x % 2 == 1) || (x < 0);
bool b = (x < 0) || (x % 2 == 1);
cout << a << "\n"; // line 1
cout << b << "\n"; // line 2
cout << (x % 2 == 1) || (x < 0); cout << "\n"; // line 3
cout << (x < 0) || (x % 2 == 1); cout << "\n"; // line 4
}