*ハノイの塔 [#c68e3446] #geshi(cpp){{ // hanoi #include <iostream> #include <string> #define FROM "A" #define TO "B" #define WORK "C" using namespace std; unsigned int counter; void solve(int x, string from, string to, string work){ if(x == 1){ cout << ++counter << ": " << from << " to " << to << endl; }else{ solve(x-1, from, work, to); cout << ++counter << ": " << from << " to " << to << endl; solve(x-1, work, to, from); } } int main() { int x; // Input the circle count cout << "Input x > "; cin >> x; counter = 0; solve(x, FROM, TO, WORK); return 0; } }}