#include <iostream>
using namespace std;
void f(int n, int a, int b, int c){
if(n==1){
cout<< "把第" << n << "個圓盤從第" << a << "根柱子移到第" << c << "根柱子" << endl;
}
else{
f(n-1, a, c, b);
cout<< "把第" << n << "個圓盤從第" << a << "根柱子移到第" << c << "根柱子" << endl;
f(n-1, b, a, c);
}
}
int main()
{
int n;
cout << "這是河內塔攻略神器,設定為共三根柱子,剛開始所有圓盤皆在第一根柱子,結束時所有圓盤皆在第三根柱子" << endl;
cout << "請輸入圓盤數:";
while(cin >> n){
int a = 1, b = 2, c = 3;
f(n, a, b, c);
cout << endl;
cout << "請輸入圓盤數:";
}
return 0;
}