⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pr22023.cpp

📁 c++编程宝典源码及Quincy99编译器 是《标准C++编程宝典》电子工业出版社的光盘
💻 CPP
字号:
////////////////////////////////////////
// File Name: pr22023.cpp
////////////////////////////////////////
#include <iostream>
#include <bitset>

////////////////////////////////////////
// Display a bitset.
////////////////////////////////////////
void display(std::bitset<8> bs)
{
    // Display the bitset.
    std::cout << "Bitset = ";
    for (int x=0; x<8; ++x)
        std::cout << bs[x];
    std::cout << std::endl;
}

////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
    // Create and display the first bitset object.
    std::bitset<8> bitSet;
    bitSet.set(1);
    bitSet.set(3);
    bitSet.set(5);
    bitSet.set(7);

    display(bitSet);

    // Create and display the second bitset object.
    std::bitset<8> bitSet2;
    bitSet2.set(0);
    bitSet2.set(1);
    bitSet2.set(3);
    bitSet2.set(5);
    bitSet2.set(7);

    display(bitSet2);

    // Compare the bitsets.
    if (bitSet == bitSet2)
        std::cout << "bitset1 == bitset2";
    else
        std::cout << "bitset1 != bitset2";
    std::cout << std::endl;

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -