Website Summary Files Commits Branches @commit @diff @stats
path: root / Week14 / Exercise03.cpp
diff options
context:
space:
mode:
1 files changed, 16 insertions, 0 deletions
-rw-r--r--Week14/Exercise03.cpp16
diff --git a/Week14/Exercise03.cpp b/Week14/Exercise03.cpp
new file mode 100644
index 0000000..0675116
--- /dev/null
+++ b/Week14/Exercise03.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+
+int main() {
+ unsigned int x;
+ std::cin >> x;
+
+ unsigned bitCounter = 0;
+ while (x > 0) {
+ bitCounter ^= x;
+ x >>= 1;
+ }
+
+ std::cout << (bitCounter & 1) << std::endl;
+
+ return 0;
+}