Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void function(int n, int a, int b, int c)
- {
- if (n == 1)
- cout << a << " " << b << endl;
- else
- {
- function(n - 1, a, c, b);
- cout << a << " " << b << endl;
- function(n - 1, c, b, a);
- }
- }
- int main()
- {
- int n;
- cin >> n;
- function(n, 1, 2, 3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement