Advertisement
Josif_tepe

Untitled

Feb 18th, 2025
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. #include <cmath>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. void rec(int x) {
  8.     if(x > 5) {
  9.         return;
  10.     }
  11.     rec(x + 1);
  12.     cout << x << endl;
  13. }
  14. int main()
  15. {
  16.    
  17.     rec(1);
  18.  
  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