#include<bits/stdc++.h>
using namespace std;
#define N 1005
int n;
inline int read() {
int x = 0;
bool f = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar())
x = (x << 1) + (x << 3) + ch - '0';
return f ? x : (~(x - 1));
}
void solve(int n,char a,char b,char c) {
int t = 1;
if (n == 1)
cout<<"1:"<<a<<"->"<<c<<endl;
else {
solve(n - 1, a, c, b);
cout<<n<<":"<<a<<"->"<<c<<endl;
// printf("%d:%c->%c\n",&a,&c);
solve(n - 1, b, a, c);
}
}
int main() {
n = read();
char a = 'A', b = 'B', c = 'C';
solve(n,a,b,c);
return 0;
}
标签:char,ch,int,d093,汉诺塔,solve,getchar
From: https://www.cnblogs.com/pigAlg/p/17227908.html