若int a=1,b=2;则a "或" b的值是 若a=1,b=2,则a|b的值为多少,又是怎么算,c语言的
\u82e5int a=1,b=2; \u5219a|b\u7684\u503c\u662f_______.|\u4e3a\u201c\u6309\u4f4d\u6216\u201d\u8fd0\u7b97\u7b26\uff0c\u89c4\u5219\uff1a\u4e24\u4e2a\u76f8\u5e94\u7684\u4e8c\u8fdb\u5236\u4f4d\u4e2d\u53ea\u8981\u6709\u4e00\u4e2a\u4e3a1\uff0c\u8be5\u4f4d\u7ed3\u679c\u4e3a1.\u53731|1=1,1|0=1,0|1=1,0|0=0\u3002
a\uff0cb\u5316\u4e3a\u4e8c\u8fdb\u5236\u4e3a01\uff0c10
a|b=01|10=11
11\u5316\u4e3a\u5341\u8fdb\u5236\u4e3a3
#include
int main(int argc, char *argv[])
{ int a,b,c;
a=1;
b=2;
c=a|b;
printf("%d\n",c);//\u4f4d\u8fd0\u7b97\u6216:\u5148\u628aa,b\u6362\u6210\u4e8c\u8fdb\u523601\u548c10\uff0c\u6216\u8fd0\u7b97\u540e\u4e3a11\uff0c\u518d\u8f6c\u5316\u6210\u5341\u8fdb\u5236\u5c31\u662f3 return 0;
}
\u671b\u91c7\u7eb3
按照上面的分析,你问题的答案应该为1.
如果你要问的是 a||b 那答案就是1了。
因为a和b都是非零数,对它们求“或”之后结果就是1了。
扩展阅读:若已定义int a 5 下面对 1 ... auto int b 1 ... int a 2+ 1 2 3 ... int x 2 z ++x+1 ... int a[3][4] ... 若有定义int a 8 b 5 c ... int a 10 1 2 ... int a=2 ... int a 10 p a ...