汉诺塔非递归算法.我只是将盘子的数量等于2,3的情况代到网上别人给的算法中验证了一下,没有错。并没有证明算法的正确性。算法是否有效,有待大家证明。 8}!WJ2[R
YZ^;xV
include <iostream> HY7#z2L
#include <stdlib.h> kR;Hb3hb
QpMi+q
Y
#ifdef _WIN32 5*Y(%I<
using namespace std; ,CQg6-[
#endif -|&&lxrwh
hxuc4C\J
static void hanoi(int height) MJI`1*(
{ :0j_I\L
int fromPole, toPole, Disk; rIWQD%Afm
int *BitStr = new int[height], //用来计算移动的盘的号码 %8g1h)F"S
*Hold = new int[height]; //用来存贮当前的盘的位置。hold[0]为第一个盘所在的柱号 7F wot&