Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int startNumber, endNumber;
- cin >> startNumber >> endNumber;
- for (int number = startNumber; number <= endNumber; number++)
- {
- //всички цифри на число
- //654321
- int firstDigit = number / 100000;
- int secondDigit = number / 10000 % 10;
- int thirdDigit = number / 1000 % 10;
- int forthDigit = number / 100 % 10;
- int fifthDigit = number / 10 % 10;
- int sixthDigit = number % 10;
- int sumEven = secondDigit + forthDigit + sixthDigit;
- int sumOdd = firstDigit + thirdDigit + fifthDigit;
- if (sumEven == sumOdd) {
- cout << number << " ";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment