#include<stdio.h>
void Hanoi(int n,char a,char b,char c)
{
if(n==1)
printf("move %c to %c \n",a,c);
else
{
Hanoi(n-1,a,c,b);
printf("move %c to %c \n",a,c);
Hanoi(n-1,b,a,c);
}
}
void main()
{
int n;
char A = '1',B = '2',C = '3';
printf("enter the number of disks");
scanf("%d",&n);
printf("the solution for n = %d\n",n);
Hanoi(n,A,B,C);
}
来源:CSDN
作者:yinhua405
链接:https://blog.csdn.net/yinhua405/article/details/70232223