标签:
#include<cstdio> #include<cmath> #include<cctype> #include<iostream> #include<vector> #include<cstring> #include<algorithm> #include<map> #include<set> #include<cstddef> #include<sstream> #include<cstdlib> #include<stack> #include<queue> using namespace std; void f(int n,char a,char b,char c) { if(n==1) printf("1 from %c to %c\n",a,c);///分解的最小问题一定是1怎么移动 else { f(n-1,a,c,b); printf("%d from %c to %c\n",n,a,c);///分解步骤:最简单的访问就是输出 f(n-1,b,a,c); } } int main() { int siz=0; int n; cin>>n; for(int i=1;i<=n;++i) { siz*=2; siz++; } cout<<siz<<endl; f(n,‘A‘,‘B‘,‘C‘); return 0; }
标签:
原文地址:http://www.cnblogs.com/weiweiyi/p/5124273.html