bitset内置函数与使用方法

#include <bitset>
bitset<N> a, b;
a[x] = y; //赋值
a ^= b;
a |= b;
a &=b;
a <<= 1;
a >>= 1;
a.set() //全部置为1
a.reset() //全部置为0
a.flip() //0变1 1变0
a.flip(i) //位置i取反
a.count() //1的个数
a.none() //返回有没有1 有false 没有true 
a.any() //返回有没有1 有true 没有false
a.to_ulong() //返回usigned long 结果
a.to_string() //返回字符串
a._Find_first() //返回第一个1的位置
a._Find_next(i) //返回i之后是1的第一个位置

猜你喜欢

转载自www.cnblogs.com/tkandi/p/9447741.html