C++中怎么用类的方式实现汉诺他塔问题

2025年03月19日 13:05
有2个网友回答
网友(1):

#include
useing namespace std;
void move(char getone,char putone)
{
cout<"<void hanoi(int n,char one,char tow,char three)
{
void move(char getone,char putone);
if(n==1) move(one,three);
else
{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,ome,three);
}
}
int main()
{
void hanoi(int n,char one,char two,char three);
int m;
cout<<"Enter the number of disks:";
cin>>m;
cout<"the steps to moving"<hanoi(m,'A,'B','C');
}

大概就是这个意思,慢慢看吧

网友(2):

递归调用对象,