汉诺塔问题看不懂,请大虾们指点,我是很菜
void move (char x,char y)
{
printf("%c-->%c\n",x,y);
}
viod hanoi(int n,char one,char two,char three));//这个递归函数搞不明白,整个就不知道怎么回事
{ if(n==1)move(one,three);
else
{
hanoi(n-1,one,three,two);//在这个语句先不段的调用自己,直到n=1为止?再向下进行?
move(one,three);
hanoi(n-1,two,one,three);
}
}
main()
{
int m;
printf("input the number of disks:");
scanf("%d,&m);
printf("the step to moving %3d disks:\n",m);
hanoi(m,'A','B','C');
}