#include <stdio.h>
#include <stdlib.h>
//河内之塔 递归实现
void hanoi(int n,char A,char B,char C);
int main(int argc, char *argv[])
{
int n;
printf("输入盘数:");
scanf("%d",&n);
hanoi(n,'A','B','C');
system("PAUSE");
return 0;
}
void hanoi(int n,char A,char B,char C)
{
if(n==1)
{
printf("Move sheet %d from %c to %c/n",n,A,C);
}
else
{
hanoi(n-1,A,C,B);
printf("Move sheet %d from %c to %c/n",n,A,C);
hanoi(n-1,B,A,C);
}
}