📄 hanoi.cpp
字号:
#include<iostream.h>
void Move(char getone,char putone)
{
cout<<getone<<"->"<<putone<<endl;
}
void Hanoi(int n,char one,char two,char three)
{
if(n==1)Move(one,three);
else
{
Hanoi(n-1,one,three,two);
Move(one,three);
Hanoi(n-1,two,three,one);
}
}
void main()
{
int n;
cout<<"Enter the number of plate:"<<endl;
cin>>n;
cout<<"the steps of moving"<<n<<"plates:"<<endl;
Hanoi(n,'A','B','C');
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -