Bit manipulation 具有增量-减量的位运算符
这个C代码的输出是什么Bit manipulation 具有增量-减量的位运算符,bit-manipulation,bitwise-operators,Bit Manipulation,Bitwise Operators,这个C代码的输出是什么 #include <stdio.h> void main() { int a = 5, b = -7, c = 0, d; d = ++a && ++b || ++c; printf("\n%d%d%d%d", a, b, c, d); } #包括 void main() { int a=5,b=-7,c=0,d; d=++a&&++b | |++c;
#include <stdio.h>
void main()
{
int a = 5, b = -7, c = 0, d;
d = ++a && ++b || ++c;
printf("\n%d%d%d%d", a, b, c, d);
}
#包括
void main()
{
int a=5,b=-7,c=0,d;
d=++a&&++b | |++c;
printf(“\n%d%d%d%d”,a、b、c、d);
}
比分是6-60-1。
我不明白逻辑AND的优先级如何大于OR。发生的情况是,
a
由1以及b
使用++a、++b
来确认。
++a&&++b
的结果是正确的(等于1),这正是d
得到的结果
因为它读的是
true | |++c
,所以它不会检查右侧,因为结果显然是true
,这就是为什么c等于0。这里没有按位运算符。