Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <math.h>
- 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