Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- int start, end;
- cin >> start;
- cin >> end;
- for (int num = start; num <= end; num++)
- {
- int number = num;
- string numberStr = to_string(number);
- int evenSum = 0;
- int oddSum = 0;
- for (int i = 0; i < 6; i++)
- {
- int digit = numberStr[i] - 48;
- if ((i+1) % 2 == 0)
- {
- evenSum += digit;
- }
- else
- {
- oddSum += digit;
- }
- }
- if (evenSum == oddSum)
- {
- cout << number << " ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement