河内之塔
#include <stdio.h>void hanoi(int n, char a, char b, char c)
{
if(n==1)
{
printf("move sheet %d from %c to %c\n", n, a, c);
}
else
{
hanoi(n-1, a, c, b);
printf("move sheet %d from %c to %c\n", n, a, c);
hanoi(n-1, b, a, c);
}
}
int main(void)
{
int n;
printf("请输入盘数:");
scanf("%d", &n);
hanoi(n, 'a', 'b', 'c');
return 0;
}
求高手解释函数void hanoi中的具体意思 谢谢了