aboutsummaryrefslogtreecommitdiff
path: root/challenge-069/ash/cpp/ch-2.cpp
blob: 74cae7876bfab8de64ac9d7e9934c0bc480c22a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Compile as: g++ -std=c++17 ch-2.cpp

#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<bool> bits;
    bits.push_back(0);

    for (int n = 2; n <= 8; n++) {
        int size = bits.size();
        bits.push_back(0);

        cout << 'S' << n << " = ";

        for (int m = 1; m <= size; m++)
            bits.push_back(!bits[size - m]);

        for (auto x : bits) cout << x;
        cout << endl;
    }
}