Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void move(int n, int x, int y) {
  6. if (n < 1) return;
  7. else {
  8. move(n - 1, x, y);
  9. cout << n << " " << x << " " << 2 << "\n";
  10. move(n - 1, y, x);
  11. cout << n << " " << 2 << " " << y << "\n";
  12. move(n - 1, x, y);
  13. }
  14. }
  15.  
  16. int main() {
  17. int n;
  18. cin >> n;
  19. move(n, 1, 3);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement