汉诺塔是这样一种小游戏:
有三根柱子。一开始,若干张圆盘按照上小下大的顺序串在第一根柱子上。而游戏的目标为将所有圆盘全部移动到第三根柱子上去,并且仍要保持上小下大的顺序。而且要求:
①每次只能移动一张圆盘。
②较大的圆盘不可以放在较小的圆盘上面。
比如说,在这一步我想把第一根柱子上的圆盘移动到第二根柱子上去,行不行呢?不行。
因为这样一移动,大圆盘就在小圆盘上面了。
所以,我们只能把它移动到第三根空的柱子上去。
源代码:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define MAX_PLATES 15
#define SPACE 32
#define EMPTY 51316
#define CUR 32118
int nTimesTwo(int n){
int product = 1;
for(int i = 0; i < n; i++) product*=2;
return product;
}
void cls(){
system("cls");
}
void pause(){
system("pause");
}
void tab(int times){
for(int