diff options
Diffstat (limited to 'challenge-069/ash/cpp/ch-2.cpp')
| -rw-r--r-- | challenge-069/ash/cpp/ch-2.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-069/ash/cpp/ch-2.cpp b/challenge-069/ash/cpp/ch-2.cpp new file mode 100644 index 0000000000..74cae7876b --- /dev/null +++ b/challenge-069/ash/cpp/ch-2.cpp @@ -0,0 +1,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; + } +} |
