参考我之前的问题,如何在 C++ 中实现 AND 和 OR 操作
我的下一个问题是,有时它会输出一些奇怪的数字,例如 110010 & 010101 = 110591。为什么会这样?
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
long int s;
long int l;
long int r;
cin>>s;
cout<<endl;
cin>>l;
cout<<setfill('0')<<setw (5)<<s<<endl<<setfill('0')<<setw (5)<<l<<endl;
r=s|l;
cout<<r<<endl;
return 0;
}