exp06_02.c
来自「《C语言程序设计教程、实验与练习》 源文件下载」· C语言 代码 · 共 23 行
C
23 行
void move(int x,int y)
{
printf("move the top plate of %dth hole-->%dth hole\n",x,y);
}
void hanoi(int n,int one,int two,int three)
{
if(n==1)
move(one,three);
else
{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
main()
{
int m;
printf("input the number of diskes:");
scanf("%d",&m);
printf("The step to moving %3d diskes:\n",m);
hanoi(m,1,2,3);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?