ProgramAlgTrain/20240901/6261/6261.cpp

22 lines
406 B
C++
Raw Normal View History

2024-09-01 14:01:13 +00:00
#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);
}