汉诺塔的程序把我弄迷糊了!高人指点一下!
/*输出汉诺塔移动的步骤*/#include<stdio.h>
void 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 moveing %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);;
}
[此贴子已经被作者于2007-2-10 9:39:38编辑过]