wigllytest

Untitled

Aug 10th, 2020
47
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. int start, end;
  9. cin >> start;
  10. cin >> end;
  11.  
  12. for (int num = start; num <= end; num++)
  13. {
  14. int number = num;
  15. string numberStr = to_string(number);
  16. int evenSum = 0;
  17. int oddSum = 0;
  18.  
  19. for (int i = 0; i < 6; i++)
  20. {
  21. int digit = numberStr[i] - 48;
  22. if ((i+1) % 2 == 0)
  23. {
  24. evenSum += digit;
  25. }
  26. else
  27. {
  28. oddSum += digit;
  29. }
  30. }
  31. if (evenSum == oddSum)
  32. {
  33. cout << number << " ";
  34. }
  35.  
  36. }
  37.  
  38.  
  39.  
  40. return 0;
  41. }
RAW Paste Data