aboutsummaryrefslogtreecommitdiff
path: root/challenge-069/ash/cpp/ch-2.cpp
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2020-07-13 22:34:24 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2020-07-13 22:34:24 +0100
commitd7fd2ed4a619f9b1bbf5a506f7c3ad909b6e6598 (patch)
treee685915f4f2a0e783abf748b1a5dbbaf89647d4e /challenge-069/ash/cpp/ch-2.cpp
parent56b581b809053def830e5864731e9b4d56148732 (diff)
downloadperlweeklychallenge-club-d7fd2ed4a619f9b1bbf5a506f7c3ad909b6e6598.tar.gz
perlweeklychallenge-club-d7fd2ed4a619f9b1bbf5a506f7c3ad909b6e6598.tar.bz2
perlweeklychallenge-club-d7fd2ed4a619f9b1bbf5a506f7c3ad909b6e6598.zip
- Moved C++ solution to the correct folder.
Diffstat (limited to 'challenge-069/ash/cpp/ch-2.cpp')
-rw-r--r--challenge-069/ash/cpp/ch-2.cpp24
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;
+ }
+}