#include<iostream>
usingnamespace std;
intmain()
{voidhanoi(int n,char one,char two,char three);
intm;
cout<<"inputthe number of diskes:";
cin>>m;
cout<<"Thesteps of moving "<<m<<" disks:"<<endl;
hanoi(m,'A','B','C');
return0;
}
voidhanoi(int n,char one,char two,char three)
//将n个盘从one座借助two座,移到three座
{voidmove(char x,char y);
if(n==1)move(one,three);
else
{hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
voidmove(char x,char y)
{cout<<x<<"-->"<<y<<endl;}