fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void output(int number, int from, int to) {
  5. cout << number << " " << from << " " << to << endl;
  6.  
  7.  
  8. }
  9.  
  10. void move(int n, int a, int b, int c) {
  11. if (n == 0)
  12. return;
  13. move(n - 1, a, c, b);
  14. output(n, a, b);
  15. move(n - 1, c, b, a);
  16.  
  17.  
  18. }
  19. int main()
  20. {
  21. int n;
  22. cin >> n;
  23. move(n, 1, 3, 2);
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 15232KB
stdin
2
stdout
1 1 2
2 1 3
1 2 3