#include <iostream>
#include <stack>
using namespace std;
stack<int> s[3];
void move(int x, int y,int n) {
int tmp = s[x-1].top();
s[x-1].pop();
s[y-1].push(tmp);
cout <<"Move "<<n<<" from "<<x<<" to "<<y << endl;
}
void hanoi(int A, int B, int C, int n) {
if (n == 1) {
move(A, C,n);
return ;
}
hanoi(A, C, B, n - 1);
move(A, C,n);
hanoi(B, A, C, n - 1);
}
int main() {
int n;
cin >> n;
for (int i = n; i >= 1; i--) {
s[0].push(i);
}
hanoi(1, 2, 3, n);
return 0;
}
0.0分
0 人评分