#include<iostream>
using namespace std;
void move(char a,char c)
{
cout<<a<<"-->"<<c;
cout<<endl;
}
int hano(int n,char a ,char b , char c)
{
if (n == 1)
move(a,c);
else
{
hano(n-1,a,c,b);
move(a,c);
hano(n-1,b,a,c);
}
}
int main()
{
int n;
cin>>n;
hano(n,'A','B','C');
return 0;
}
Sample:
3
Output:
A --> C
A --> B
C --> B
A --> C
B --> A
B --> C
A --> C