Bitset

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<bitset>
using namespace std;


int main(){
    bitset<16>A;
    bitset<16>B(0xfa2);
    bitset<16>C(string("100000"));
    
    cout<<A<<endl;
    cout<<B<<endl;
    cout<<C<<endl;
    
    cout<<(A^=B)<<endl;
    cout<<(A|=B)<<endl;
    cout<<(A^=B)<<endl;
    
    cout<<(A<<=1)<<endl;
    cout<<(A<<1)<<endl;
    cout<<(~A)<<endl;
    
    cout<<(A==B)<<endl;
    cout<<(A!=B)<<endl;
    
    cout<<(A&B)<<endl;
    cout<<(A|B)<<endl;
    
    cout<<A.size()<<endl;
    cout<<A.count()<<endl;
    cout<<A.any()<<endl;
    cout<<A.none()<<endl;
   cout<<A.test()<<endl;

A.
set(); int p=0,x=1; A.set(p); A.set(p,x); A.reset(); A.reset(p); A.flip(); A.flip(p); A.to_ulong(); A.to_string(); return 0; }

 

posted @ 2018-04-04 11:21  ws_zzy  阅读(151)  评论(0编辑  收藏  举报