Advertisement
Josif_tepe

Untitled

Jan 12th, 2023
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. using namespace std;
  5.  
  6. void rec(int number) {
  7.     if(number > 5) {
  8.         return;
  9.     }
  10.    
  11.     rec(number + 1);
  12.    
  13.     cout << number << endl;
  14. }
  15.  
  16. int main() {
  17.    
  18.     rec(1);
  19.     return 0;
  20. }
  21. // rec(1) --> rec(2)  | cout << 1 << endl;
  22. // rec(2) --> rec(3)  | cout << 2 << endl;
  23. // rec(3) --> rec(4)  | cout << 3 << endl;
  24. // rec(4) --> rec(5)  | cout << 4 << endl;
  25. // rec(5) --> rec(6)  | cout << 5 << endl;
  26. // rec(6)
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement