ProgramAlgTrain/20240901/6261/6261.cpp
2024-09-01 22:01:13 +08:00

22 lines
406 B
C++

#include <ios>
#include <iostream>
void HLT(int n,char a,char b,char c){
if(n==1){
std::cout<<a<<"->"<<n<<"->"<<c<<"\n";
return;
}
HLT(n-1, a, c, b);
std::cout<<a<<"->"<<n<<"->"<<c<<"\n";
HLT(n-1, b, a,c);
}
int main(){
std::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0);
int n;
char a,b,c;
std::cin>>n>>a>>c>>b;
HLT(n, a, b, c);
}