Advertisement
B3ar6

przedzial - rekurencja

Dec 21st, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int sum(int min, int max)
  5. {
  6.     if(min<max)
  7.         return sum(min+1, max) + min;
  8. }
  9.  
  10. int main()
  11. {
  12.     int min, max;
  13.     cout << "PODAJ MINIMALNA LICZBE PRZEDZIALU : ";
  14.     cin >> min;
  15.     cout << "PODAJ MAKSYMALNA LICZBE PRZEDZIALU : ";
  16.     cin >> max;
  17.    
  18.     cout << "WYNIK WSZYSTKICH LICZB JEDNOCYFROWYCH ROWNA SIE : " << sum(min, max) << endl << endl;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement