Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Equal sums (even/odd numbers)

JOHNYTHEWINNER Feb 17th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6. #include <string>
  7.  
  8. int main()
  9. {
  10.     int number1;
  11.     int number2;
  12.     cin >> number1;
  13.     cin >> number2;
  14.     int sumeven = 0;
  15.     int sumodd = 0;
  16.     for (int i = number1; i <= number2; i++) {
  17.         string temp = to_string(i);
  18.         for (int m = 0; m <= 5; m++) {
  19.             char number = temp.at(m);
  20.             if (m % 2 == 0) {
  21.                 sumodd += number;
  22.             }
  23.             else {
  24.                 sumeven += number;
  25.             }
  26.         }
  27.         if (sumodd == sumeven)
  28.         {
  29.             cout << temp << " ";
  30.         }
  31.         sumeven = 0;
  32.         sumodd = 0;
  33.     }
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top