Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char** argv)
  9. {
  10. int przedzial,sumad=0,sumau=0,sumaw=0;
  11.  
  12. cout << "Podaj przedzial ";
  13. cin >> przedzial;
  14.  
  15. for (int i=0; i<=przedzial ; i++)
  16. {
  17. if (i % 2 == 0)
  18. {
  19. sumad+=i;
  20. }
  21. }
  22.  
  23.  
  24. for (int i=0; i>=-przedzial ; i--)
  25. {
  26. if (i %2 == 0)
  27. {
  28. sumau+=i;
  29. }
  30. }
  31.  
  32. sumaw=sumad+sumau;
  33. cout << sumaw;
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement