提交时间:2023-10-05 09:11:53
运行 ID: 105048
#include<bits/stdc++.h> using namespace std; void work(int x,char a,char b,char c) { if(x==1){ cout<<a<<"->"<<c<<endl; return; } work(x-1,a,c,b); cout<<a<<"->"<<c<<endl; work(x-1,b,a,c); } int main() { int n; cin>>n; work(n,'A','B','C'); return 0; }