📄 xt4-9.cpp
字号:
#include <iostream>
using namespace std;
int main()
{void hanoi(int n,char one,char two,char three);
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;
}
void hanoi(int n,char one,char two,char three)
//将n个盘从one座借助two座,移到three座
{void move(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);
}
}
void move(char x,char y)
{cout<<x<<"-->"<<y<<endl;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -