有以下程序 main(){ int a=1,b=2,c=3,x; X=(a^b)&c; printf("%d\n",x);} 程序的运行结果是

admin2015-08-14  26

问题 有以下程序
    main(){
    int a=1,b=2,c=3,x;
    X=(a^b)&c;
    printf("%d\n",x);}
    程序的运行结果是

选项 A、1
B、2
C、3
D、0

答案C

解析 1、2、3的二进制形式分别为00000001、00000010、00000011。首先计算1与2的或运算,即1^2=(00000001)^(000000lO)=00000011,再将其与3进行“与”运算,结果为(00000011)&(00000011)=00000011,即十进制数3。
转载请注明原文地址:https://kaotiyun.com/show/cUDp777K
0

最新回复(0)