首页 > 试题广场 >

在横线处补充( ...

[单选题]
在横线处补充(      )可以结果输出值为80000007(      )
#include <stdio.h>

int convert(int i)
{
return ___________________;
}

int main()
{
int value = 7;

printf( "%x\n", convert(value) );

return 0;
}
  • i|=1&lt;&lt;31;
  • i&amp;=1&lt;&lt;31;
  • i&amp;=~(1&lt;&lt;31);
  • i^=1&lt;&lt;31;
解释下A选项:
&lt;  代表 <
i|=1<<31;    按照优先级,先执行<<操作,再是 | ,最后是 =

1<<31 
 =>          1000 0000 0000 0000 0000 0000 0000 0000 
| 运算       0000 0000 0000 0000 0000 0000 0000 0111
=>            1000 0000 0000 0000 0000 0000 0000 0111  
转成十进制
=>8000 0007

发表于 2019-09-09 23:02:06 回复(0)

运算规则:0|0=0;  0|1=1;  1|0=1;   1|1=1;

     即 :参加运算的两个对象只要有一个为1,其值为1

编辑于 2019-09-26 09:35:15 回复(0)