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