提交时间:2024-03-31 12:36:13
运行 ID: 44570
#include <bits/stdc++.h> using namespace std; int s = 0; void move(int n,char a,char b,char c) { if(n == 1) { s += 1; cout<<a<<"->"<<c<<endl; } else { move(n-1,a,c,b); move(1,a,b,c); move(n-1,b,a,c); } return; } int main() { int n; cin >> n; move(n,'A','B','C'); cout << s; return 0; }