SHARE
TWEET

222

a guest Oct 23rd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long A, B, sM1=0, sM2=0;
  6.  
  7. int main()
  8. {
  9.     cin >> A;
  10.     cin >> B;
  11.     for(int i = A; i <= B; i++)
  12.     {
  13.         if (i % 2 == 0)
  14.         {
  15.             sM1+=i;
  16.         }
  17.         if(i % 2 != 0)
  18.         {
  19.             sM1-=i;
  20.         }
  21.     }
  22.  
  23.     cout << sM1 - sM2;
  24. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top