Hanoi塔问题
Hanoi塔问题
#include<stdio.h>
int move(int n,int x,int y,int z)
{
if(n==1)
printf("%c-->%c\n",x,z);
else
{
move(n-1,x,z,y);
printf("%c-->%c\n",x,z);
move(n-1,y,x,z);
}
}
int main()
{
int h;
printf("\ninput number:\n");
scanf("%d",&h);
printf("the step to moving %2d dislike :\n",h);
move(h,'a','b','c');
}