C++ 按相反顺序打印表达式时得到不同的结果

C++ 按相反顺序打印表达式时得到不同的结果,c++,operator-precedence,C++,Operator Precedence,为什么我在第三行得到不同的结果? 输出为: 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 <<

为什么我在第三行得到不同的结果? 输出为:

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
}    
#包括
使用名称空间std;
int main()
{
int x=-3;
布尔a=(x%2==1)| |(x<0);
布尔b=(x<0)| |(x%2==1);
不能因为,哪个
操作符
(x % 2 == 1)
(cout << (x % 2 == 1)) || (x < 0);
cout << (x % 2 == 1 || x < 0);