diff options
| Commit | 3d9b1b6f61a26f506cea1959fd0dfb430259ab35 (patch) | |
|---|---|---|
| Author | 2026-01-18 15:30:07 +0200 | |
| Committer | 2026-01-18 15:30:07 +0200 | |
| Files | e36ee10f828ae481e9b156179dafdd5b370904e3 /Week14/Exercise03.cpp | |
| upp-2025-solutions-main.tar upp-2025-solutions-main.tar.gz upp-2025-solutions-main.zip | ||
| Parent | 5c3b97fb2572ce8940439abd0652d2a7f7a623bd (diff) | |
1 files changed, 16 insertions, 0 deletions
| -rw-r--r-- | Week14/Exercise03.cpp | 16 |
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; +} |
