C++实现以上计算,参考代码如下:
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout << "a、b的与 "<<(a&b)<<endl;
cout << "a、b的或 "<<(a|b)<<endl;
cout << "a的非 "<<(~a)<<endl;
cout << "b的非 "<<(~b)<<endl;
cout << "a、b的
异或 "<<(a^b)<<endl;
return 0;
}
追答![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/9358d109b3de9c8228bd53f86381800a18d843e9?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
运行结果:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/9358d109b3de9c8228be53f86381800a18d843ea?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)