汉诺塔非递归算法.我只是将盘子的数量等于2,3的情况代到网上别人给的算法中验证了一下,没有错。并没有证明算法的正确性。算法是否有效,有待大家证明。 CvdN"k
2`-Bs
include <iostream> ),!qTjD
#include <stdlib.h> !<h)w#>en
Uw:"n]G]D?
#ifdef _WIN32 }-`4DHgq
using namespace std; 9tnD=A<PS
#endif ;F Eqe49
moE2G?R
static void hanoi(int height) rT>wg1:
{ 3(UVg!t
int fromPole, toPole, Disk; D m9sL!
int *BitStr = new int[height], //用来计算移动的盘的号码 V.2_i*
*Hold = new int[height]; //用来存贮当前的盘的位置。hold[0]为第一个盘所在的柱号 8?C5L8)
char Place[] = {'A', 'C', 'B'}; Ts x>&W