void hanoi(int n, char a, char b, char c)
{
if (n > 0)
{
hanoi(n - 1, a, c, b);
cout << a << "->" << b << endl;//move
hanoi(n - 1, c, b, a);
}
}
- void hanoi(int n, char a, char b, char c)
- {
- if (n > 0)
- {
- hanoi(n - 1, a, c, b);
- cout << a << "->" << b << endl;//move
- hanoi(n - 1, c, b, a);
- }
- }
void hanoi(int n, char a, char b, char c)
{
if (n > 0)
{
hanoi(n - 1, a, c, b);
cout << a << "->" << b << endl;//move
hanoi(n - 1, c, b, a);
}
}