#include using std::cin; using std::cout; using std::cerr; using std::endl; void solve(int count, int source, int destination, int spare){ cerr << "solve(" << count << ", " << source << ", " << destination << ", " << spare << ")\n"; if( count == 1){ cout << "Move the top disk from " << source << " to " << destination << endl; }else{ solve( count-1, source, spare, destination ); solve( 1, source, destination, spare); solve( count-1, spare, destination, source); } } int main(){ int numRings = -1; int startingTower = 1; int spareTower = 2; int endingTower = 3; cin >> numRings; solve( numRings, startingTower, endingTower, spareTower); return 0; }