汉诺塔
void move(char x,char y)
{
cout<<x<<"-->"<<y<<endl;
}
void hanoi(int n,char one,char two,char three)
//将 n 个盘从 one 座借助 two 座,移到 three 座
{
if(n==1) move(one,three);
else
{
hanoi(n-1,one,three,two);
move(one,three);hanoi(n-1,two,one,three);
}
}
int main()
{
int m;
cout<<"input the number of diskes:";
cin>>m;
cout<<"The steps of moving "<<m<<" disks:"<<endl;
hanoi(m,'A','B','C');
return 0;
}