Advertisement
STANAANDREY

fig_rec1

Dec 29th, 2019
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void stars(int n)
  5. {
  6.     if (!n)
  7.     {
  8.         cout << endl;
  9.         return;
  10.     }
  11.  
  12.     cout << '*';
  13.     stars(n - 1);
  14. }
  15.  
  16. void tri1(int n)
  17. {
  18.     if (!n)
  19.         return;
  20.  
  21.     tri1(n - 1);
  22.     stars(n);
  23. }
  24.  
  25. void tri2(int n)
  26. {
  27.     if (!n)
  28.         return;
  29.  
  30.     stars(n);
  31.     tri2(n - 1);
  32. }
  33.  
  34. signed main()
  35. {
  36.     int n;
  37.     cin >> n;
  38.     tri1(n);
  39.     tri2(n - 1);
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement