Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- void getBool(bool* number) {
- for (int i = 3; i >= 0; i--)
- std::cin >> number[i];
- }
- int main() {
- bool numberOne[4];
- bool numberTwo[4];
- getBool(numberOne);
- getBool(numberTwo);
- bool result[5] = { false, false, false, false, false };
- int index = 0;
- bool plusOne = false;
- for (int i = 0; i < 4; i++) {
- if (!numberOne[i] && !numberTwo[i]) {
- result[index++] = plusOne;
- plusOne = false;
- }
- else if (numberOne[i] && numberTwo[i]) {
- result[index++] = plusOne;
- plusOne = true;
- }
- else if (plusOne) {
- result[index++] = false;
- result[index] = true;
- plusOne = false;
- }
- else
- result[index++] = true;
- }
- if (plusOne)
- result[index] = true;
- for (int i = 4; i >= 0; i--)
- std::cout << result[i];
- }
Add Comment
Please, Sign In to add comment