Advertisement
srtgguy

Untitled

Jun 12th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void function(int n, int a, int b, int c)
  5. {
  6.     if (n == 1)
  7.         cout << a << " " << b << endl;
  8.     else
  9.     {
  10.         function(n - 1, a, c, b);
  11.         cout << a << " " << b << endl;
  12.         function(n - 1, c, b, a);
  13.     }
  14. }
  15.  
  16. int main()
  17. {
  18.     int n;
  19.     cin >> n;
  20.     function(n, 1, 2, 3);
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement