} void hanoi(int n,char one ,char two ,char three)//把n个盘子从 one借助two移动到t here { void move(char a,char b); if(n==1) move(one,three); else { hanoi(n-1,one,three,two);//把n-1个盘子 从 one借助there移动到two move(one,three); hanoi(n-1,two,one,three);//把n-1个盘子 从 two借助one移动到there } } void move(char a,char b) { printf("%c-->%c\n",a,b); }
汉诺塔这样理解可以吗?
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-