Bitsets
来源:互联网 发布:地狱通信软件下载 编辑:程序博客网 时间:2024/06/11 20:08
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
enum Color {red,yellow,green,blue,white,black,numColors};
bitset<numColors> usedColors;
usedColors.set(red);
usedColors.set(blue);
cout << "bitfield of used colors: " << usedColors << endl;
cout << "number of used colors: " << usedColors.count() << endl;
cout << "bitfield of unused colors: " << ~usedColors << endl;
for (int c = 0; c < numColors; ++c)
{
if (usedColors[(Color)c])
{
cout << "现在使用的颜色是:" << (Color)c << endl;
}
}
}
cin.get();
}
#include <bitset>
using namespace std;
int main()
{
enum Color {red,yellow,green,blue,white,black,numColors};
bitset<numColors> usedColors;
usedColors.set(red);
usedColors.set(blue);
cout << "bitfield of used colors: " << usedColors << endl;
cout << "number of used colors: " << usedColors.count() << endl;
cout << "bitfield of unused colors: " << ~usedColors << endl;
cout << "any color: " << usedColors.any() << endl;
usedColors.reset(red);
if (usedColors.any()) {for (int c = 0; c < numColors; ++c)
{
if (usedColors[(Color)c])
{
cout << "现在使用的颜色是:" << (Color)c << endl;
}
}
}
cin.get();
}
0 0
- Bitsets
- c++ Bitsets
- C++ Bitsets
- STL Bitsets ---应用
- bitsets 易错的点
- The Standard Librarian: Bitsets and Bit Vectors
- Numbering conventions of strings and bitsets
- 【C++】 C++标准模板库(九) Bitsets
- 07.Java读取、创建xml(通过dom方式)
- css3图片背景定位全屏
- VS2013 error C4996: 'std::_Copy_impl'解决方法
- 【设计模式学习】工厂方法模式
- USB挂载小程序(无注释)
- Bitsets
- 置信度
- 人谱
- MRPT1.40 vs2010 win64编译 配置
- 四种100G QSFP28光模块介绍
- JQuery对stopPropagation()的兼容性处理
- spring-shiro最基本的配置,就这一篇入门
- Ubuntu下terminator的安装/配置/默认启动/使用
- 1040. 有几个PAT(25)