csansoon

P2.14 P27341 Control C202D

Sep 21st, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main () {
  4.    
  5.     int a, b, x;
  6.     x=0;
  7.    
  8.     while (cin >> a >> b) {
  9.         x=0;
  10.         cout << "suma dels cubs entre " << a << " i " << b << ": ";
  11.    
  12.         while (a<b) {
  13.             x+=(a*a*a);
  14.             a++;
  15.         }
  16.         if (a<=b) x+=(a*a*a);
  17.         cout << x << endl;
  18.     }
  19. }
Add Comment
Please, Sign In to add comment