ACM template --bitset Summary

For a is called the bitset: 
a.size () returns the size (number of bits) 
a.count () returns the number 1 
a.any () Returns whether there is a 
a.none () Returns whether or not a 
a. SET ( ) all turned. 1 
A. SET (P) of the + P . 1 bits become. 1 
A. SET (P, X) of the + P . 1 bits become X 
a.reset () all become 0 
a.reset (P) the first P + . 1 bits become 0 
a.flip () are all negated 
a.flip (p) of the P + . 1 bit inversion 
a.to_ulong () returns its result to unsigned long, if the error is out of range 
a.to_ullong () returns it into unsigned Long Long a result, if the error is out of range 
a.to_string () returns the result which is converted into the string
bitset<4> a ( string("1001"));
bitset<4> b ( string("0011"));

cout << (a^=b) << endl;       // 1010 
cout << (a&=b) << endl;       // 0010
cout << (a|=b) << endl;       // 0011 

cout << endl << a << endl;    // 0011
cout << b << endl << endl;    // 0011

cout << (a<<=2) << endl;      // 1100 
cout << (a>>=1) << endl;      // 0110

cout << endl << a << endl;    // 0110
cout << b << endl << endl;    // 0011

cout << (~b) << endl;         // 1100 
cout << (b<<1) << endl;       // 0110 
cout << (b>>1) << endl;       // 0001

cout << (a==b) << endl;       // false (0110==0011)
cout << (a!=b) << endl;       // true  (0110!=0011)

cout << (a&b) << endl;        // 0010
cout << (a|b) << endl;        // 0111
cout << (a^b) << endl;        // 0101

 

Guess you like

Origin www.cnblogs.com/Asurudo/p/11619279.html