Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Odd/Even - for

JOHNYTHEWINNER Feb 2nd, 2020 109 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.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.     int scoreeven = 0;
  10.     int scoreodd = 0;
  11.     int temp;
  12.     for (int i = 0; i < n; i = i++)
  13.     {
  14.         cin >> temp;
  15.         if (i % 2 == 0)
  16.         {
  17.             scoreeven += temp;
  18.         }
  19.         else
  20.         {
  21.             scoreodd += temp;
  22.         }
  23.     }
  24.     if (scoreeven != scoreodd)
  25.     {
  26.         cout << "No" << endl;
  27.         cout << "Diff = " << abs(scoreeven - scoreodd) << endl;
  28.     }
  29.     else
  30.     {
  31.         cout << "Yes" << endl;
  32.         cout << "Sum = " << scoreeven << endl;
  33.     }
  34. }
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