bitset使用

简介: 17.10使用序列1、2、3、5、8、13、21初始化一个bitset,将这些位置置位。对另一个bitset进行默认初始化,并编写一小段程序将其恰当的位置位。 #include #include using namespace std; int main() { bitset...

17.10使用序列1、2、3、5、8、13、21初始化一个bitset,将这些位置置位。对另一个bitset进行默认初始化,并编写一小段程序将其恰当的位置位。

#include<iostream>
#include<bitset>
using namespace std;
int main()
{
    bitset<32> bits("100000001000010010111");
    bitset<32> bit;
    bit.set(1);
    bit.set(2);
    bit.set(3);
    bit.set(5);
    bit.set(8);
    bit.set(13);
    bit.set(21);
}

 

相关文章
|
29天前
|
存储 算法 数据安全/隐私保护
C++ 位运算 std::bitset类的使用介绍
C++ 位运算 std::bitset类的使用介绍
17 0
|
6月前
|
算法 固态存储 数据处理
位图(bitset)的使用【STL】
位图(bitset)的使用【STL】
23 1
|
6月前
|
C++ 容器
bitset(C++实现)
bitset(C++实现)
36 0
|
6月前
|
存储 Java C++
unordered_set和unordered_map的使用【STL】
unordered_set和unordered_map的使用【STL】
139 0
|
9月前
|
存储
BitSet—位图
BitSet—位图
|
存储 C++ 索引
【C++】-- STL之unordered_map/unordered_set详解(一)
【C++】-- STL之unordered_map/unordered_set详解
280 0
【C++】-- STL之unordered_map/unordered_set详解(一)
|
C++ 容器
【C++】-- STL之unordered_map/unordered_set详解(三)
【C++】-- STL之unordered_map/unordered_set详解
【C++】-- STL之unordered_map/unordered_set详解(三)
|
存储 C++ 容器
【C++】-- STL之unordered_map/unordered_set详解(二)
【C++】-- STL之unordered_map/unordered_set详解
【C++】-- STL之unordered_map/unordered_set详解(二)
|
Linux 编译器 C++
【C++】-- STL之vector详解(二)
【C++】-- STL之vector详解
113 0
【C++】-- STL之vector详解(二)
|
存储 C++ 容器
STL—vector(一)
vector就是边长数组,相比较与数组我们需要提前规定它的容量,它可以根据运算自动改变数组的长度,我们在平时写题的时候可能会遇到爆内存的情况,这就是我们数组长度开太长的结果,在这个时候我们就可以用vector去存储 我们在使用vector的时候,需要添加头文件#include <vector>
86 0