汉诺塔非递归算法.我只是将盘子的数量等于2,3的情况代到网上别人给的算法中验证了一下,没有错。并没有证明算法的正确性。算法是否有效,有待大家证明。 [`#CXq'
6y-@iJ*ld;
include <iostream> ;V:i!u u
#include <stdlib.h> m4[ ;(1
a5dLQxb
#ifdef _WIN32 SXSgld2uS
using namespace std; h"[AOfTE$
#endif j2t7'bO_
-V*R\,>
static void hanoi(int height) x77*c._3v
{ m<<+
int fromPole, toPole, Disk; AVsDt2A
int *BitStr = new int[height], //用来计算移动的盘的号码 a(m2n.0'>
*Hold = new int[height]; //用来存贮当前的盘的位置。hold[0]为第一个盘所在的柱号 b<tNk]7
char Place[] = {'A', 'C', 'B'}; `[y^ :mj
int i, j, temp; ^rB8? kt
HDz5&