delete pics to save space
This commit is contained in:
23
history_source/信息学奥赛一本通/2.4.8.cpp
Normal file
23
history_source/信息学奥赛一本通/2.4.8.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
void hanio(int n,char a,char b,char c)
|
||||
{
|
||||
if(n==1)
|
||||
{
|
||||
cout<<a<<"->1->"<<c<<'\n';
|
||||
return;
|
||||
}
|
||||
hanio(n-1,a,c,b);
|
||||
cout<<a<<"->"<<n<<"->"<<c<<'\n';
|
||||
hanio(n-1,b,a,c);
|
||||
}
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(0);
|
||||
int n;
|
||||
char a,b,c;
|
||||
cin>>n>>a>>b>>c;
|
||||
hanio(n,a,c,b);
|
||||
cout<<flush;
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user