STL bitmap 使用

/*
description:
STL  bitmap的使用

author:Jason
date:20160521
*/
#include<stdio.h>
#include <bitset>
#include<iostream>
using namespace std;


int main()
{
    bitset<100>  mybitset;

    mybitset.set();//將所有位置爲1
    cout<<mybitset.set(2,0)<<endl;

    if(mybitset.test(1))
    {
        cout<<"bit 1 is 1"<<endl;
    }
    else
    {
        cout<<"bit 1 is 0"<<endl;
    }
    cout<<mybitset.flip()<<endl;//翻轉



    return 0;

}
發佈了118 篇原創文章 · 獲贊 16 · 訪問量 24萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章