文件名称:hanoi
介绍说明--下载内容均来自于网络,请自行研究使用
由于汉诺塔移动的次数实在太多,神庙的和尚们决定偷懒。为了虔诚地偷
懒,他们用严格的语言描述了新的规则:
1. 有三根柱子,编号为0、1、2。初始状态下,0 号柱子从底向上按照从大
到小的次序依次放置了n 个金盘。
2. 每次移动将一根柱子最顶部的一个金盘移动到另一根柱子的最顶部。在整
个操作过程中,每根柱子上的最底部的金盘必须是最大的,而其他金盘的
顺序可以和大小无关。
3. 希望通过移动达到的目标状态是,2 号柱子从底向上按照从大到小的次序
依次放置这n 个金盘。
Figure1中的移动在新的规则下是合法的,总体的移动次数也从原规则下的
15 次减少到了13 次。
编写程序,用尽量少的移动次数解决懒和尚汉诺塔问题。-Because too many times to move the Tower of Hanoi, temple monks decided to be lazy. To piously lazy, they use strict language to describe a new rule: 1. There are three columns, numbered 0,1,2. Initially, the No. 0 column the bottom up in order of descending successively placed n gold plate. 2. Each movement will be a pillar of one of the top gold plate is moved to the top of the other pillars. Throughout the operation, the bottom of each column on a gold plate must be the biggest, but the order of the other gold discs can be independent of the size. 3. hopes to achieve the goal of moving the state is on the 2nd column the bottom up in order of descending place these n gold disc in order. Figure1 The move is legal under the new rules, the overall number of moves is also reduced 15 under the original rules to the 13 times. Programming, less exhausted the number of moves to solve the Towers of Hanoi problem lazy monk.
懒,他们用严格的语言描述了新的规则:
1. 有三根柱子,编号为0、1、2。初始状态下,0 号柱子从底向上按照从大
到小的次序依次放置了n 个金盘。
2. 每次移动将一根柱子最顶部的一个金盘移动到另一根柱子的最顶部。在整
个操作过程中,每根柱子上的最底部的金盘必须是最大的,而其他金盘的
顺序可以和大小无关。
3. 希望通过移动达到的目标状态是,2 号柱子从底向上按照从大到小的次序
依次放置这n 个金盘。
Figure1中的移动在新的规则下是合法的,总体的移动次数也从原规则下的
15 次减少到了13 次。
编写程序,用尽量少的移动次数解决懒和尚汉诺塔问题。-Because too many times to move the Tower of Hanoi, temple monks decided to be lazy. To piously lazy, they use strict language to describe a new rule: 1. There are three columns, numbered 0,1,2. Initially, the No. 0 column the bottom up in order of descending successively placed n gold plate. 2. Each movement will be a pillar of one of the top gold plate is moved to the top of the other pillars. Throughout the operation, the bottom of each column on a gold plate must be the biggest, but the order of the other gold discs can be independent of the size. 3. hopes to achieve the goal of moving the state is on the 2nd column the bottom up in order of descending place these n gold disc in order. Figure1 The move is legal under the new rules, the overall number of moves is also reduced 15 under the original rules to the 13 times. Programming, less exhausted the number of moves to solve the Towers of Hanoi problem lazy monk.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
hanoi.cpp