#include <iostream>
using namespace std;
// Move function to move a single disk from one peg to another
void Move(int n, char fromPeg, char toPeg) {
cout << "Move disk " << n << " from " << fromPeg << " to " << toPeg << endl;
}
// Hanoi function to solve the Tower of Hanoi puzzle
void Hanoi(int n, char fromPeg, char toPeg, char auxPeg) {
if (n == 1) {
Move(n, fromPeg, toPeg); // Move the only disk directly when n is 1
} else {
Hanoi(n - 1, fromPeg, auxPeg, toPeg); // Move top n-1 disks from fromPeg to auxPeg, using toPeg as auxiliary
Move(n, fromPeg, toPeg); // Move the nth disk from fromPeg to toPeg
Hanoi(n - 1, auxPeg, toPeg, fromPeg); // Move the n-1 disks that we left on auxPeg to toPeg, using fromPeg as auxiliary
}
}
int main() {
int n; // Number of disks
cout << "Input the number of disks: ";
cin >> n;
cout << "Steps of moving " << n << " disks from A to B by means of C:" << endl;
Hanoi(n, 'A', 'B', 'C'); // Solve the problem with A as the source peg, B as the destination peg, and C as the auxiliary peg
return 0;
}