#不说别的 直接代码
代码
#include
using namespace std;
void move(char from , char to ){
cout<<"Move “<<from<<” to "<<to<<endl;
}
void hannuo(int n,char first,char second,char third){
if( n == 1) move(first,third);
else{
hannuo(n-1,first,third,second);
move(first,third);
hannuo(n-1,second,first,third);
}
}
int main(){
int n;
cout<<“碟子的数量:”; cin>>n;
cout<<"移动的步骤:"<<endl;
hannuo(n,'A','B','C');
return 0;
}