用递归实现汉诺塔
using namespace std; #include <iostream> #include <cstdio> void move (int n, char from, char buffer, char to){ if (n == 1) { cout << "Move" << n << " from " << from << " to " << to << endl; } else { move (n-1, from, to, buffer); move (1, from, buffer, to); move (n-1, buffer, from, to); } }