posts - 225, comments - 62, trackbacks - 0, articles - 0
   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

STL:bitset的使用

Posted on 2007-07-07 22:24 魔のkyo 阅读(1417) 评论(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;
    }
}

只有注册用户登录后才能发表评论。