汉诺塔递归
//汉诺塔
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
void hanoi(int n,char a,char b,char c)
{
if(n==1) printf("1 from %c to %c\n",a,c);
else
{
hanoi(n-1,a,c,b);
printf("%d from %c to %c\n",n,a,c);
hanoi(n-1,b,a,c);
}
}
int main()
{
int n;
scanf("%d",&n);
cout<<pow(2,n)-1<<endl;
hanoi(n,'A','B','C');
}