帮我解说一下:汉诺塔递归调用 好吗
main()
{int n;
void hanoi(int n,char a,char b, char c);
printf("\n please enter the number of disks to be moved:");
scanf("%d",&n);
hanoi(n,'a','b','c');
}
void hanoi(int n, char a,char b,char c)
{
if(n>0)
{
hanoi( n-1,a,c,b);
printf("\n Move disc %d from pile %c to %c",n,a,b);
hanoi(n-1,c,b,a);
}
}
想问一下,怎么样自己调用了自己?
[此贴子已经被作者于2004-06-07 12:19:54编辑过]