标签:
#include <iostream> using namespace std; int haino(int ,char , char ,char ); void move(char ,char,int); int main() { int n; cin>>n; cout<<((1<<n)-1)<<endl; haino(n,‘A‘,‘B‘,‘C‘); return 0; } int haino(int n,char a,char b,char c) { if(n==1) move(a,c,n); else { haino(n-1,a,c,b); move(a, c, n); haino(n-1,b,a,c); } return 0; } void move(char a, char b,int n) { cout<<n<<" from "<<a<<" to "<<b<<endl; }
标签:
原文地址:http://www.cnblogs.com/Noevon/p/5535935.html