Advertisement
Guest User

222

a guest
Oct 23rd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement