Bitset的三个基本用法

      计算机与编程 2007-9-30 11:20:00

//bitset的三个基本用法
#include
#include
using namespace std;
void main()
{
//注意:位串长有限制(<80000000?),请讨论

bitset<16> A;
//声明一个16为串,初始化各位为0

bitset<16> B(1234);
//声明一个16为串,初始化为1234的二进制

string temp("1000010000111111");
bitset<16> C(temp);

//将字符串temp转换为位串
//显示位串:

cout << "Bitset-A:"<< A <<"\n";
cout << "Bitset-B:"<< B <<"\n";
cout << "Bitset-C:"<< C <<"\n";
}

标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}