Posted on 2007-07-07 22:24
魔のkyo 阅读(1433)
评论(0) 编辑 收藏 引用 所属分类:
STL
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
const bitset<32> mask(0xFFFFFF00);
cout << "mask = " << mask << endl;
bitset<32> x;
cout << "Enter a 32-bit bitset in binary: " << flush;
if (cin >> x) {
cout << "x = " << x << endl;
cout << "As ulong: " << x.to_ulong() << endl;
cout << "And with mask: " << (x & mask) << endl;
cout << "Or with mask: " << (x | mask) << endl;
}
}