bitset-c++
参考博客链接:http://c.biancheng.net/view/406.html
初始化
include
bitset<30> ans;
表示定义了一个30位的bitset类型对象,初始值为0
ans[0]~ans[29]
bitset 有许多成员函数,有些成员函数执行的就是类似于位运算的操作。bitset 成员函数列表如下:
bitset
bitset
bitset
bitset
bitset
bitset
bitset
bitset
bitset
bitset
bitset
reference operator[] (size_t pos); //返回对第 pos 位的引用
bool operator[] (size_t pos) const; //返回第 pos 位的值
reference at(size_t pos); //返回对第 pos 位的引用
bool at (size_t pos) const; //返回第 pos 位的值
unsigned long to_ulong() const; //将对象中的0、1串转换成整数
string to_string () const; //将对象中的0、1串转换成字符串(Visual Studio 支持,Dev C++ 不支持)
size_t count() const; //计算 1 的个数
size_t size () const; //返回总位数
bool operator == (const bitset
bool operator != (const bitset
bool test(size_t pos) const; //测试第 pos 位是否为 1
bool any() const; //判断是否有某位为1
bool none() const; //判断是否全部为0
bitset
bitset
bitset
bitset
bitset
bitset

浙公网安备 33010602011771号