求解,hanoi问题
# include <stdio.h>int main()
{
void hanoi(int n,char one,char two,char three);
int m;
printf("input the number of diskes:");
scanf("%d",&m);
printf("the step to move %d diskes:\n",m);
hanoi(m,'a','b','c');
}
void hanoi(int n,char one,char two,char three)
{
void move (char x,char y);
if ( n == 1)
move (one ,three);
else
{
hanoi(n-1,one, three, two);
move(one,three);
hanoi(n-1, two, one, three);
}
}
void move (char x, char y)
{
printf("%c-->%c\n",x,y);
}
我看不懂
else
{
hanoi(n-1,one, three, two);
move(one,three);
hanoi(n-1, two, one, three);
}
是怎么执行下去
怎么个递归法。