漢諾塔的非遞歸(演示、動畫)
Hanoi,
非遞歸
,
演示
,
動畫效果
kensta
有動畫演示,
move2()
是標準解的調用
move()
是用于演示動畫或顯示移動秩序和包含監測有無錯誤移動的調用
使用
Borland c++ 3.0(Turbo c++ 3.0,Turbo c 2.0
也可
)
編譯通過,圖形方式使用
Tc
的
bgi
*/
/*************************************/
/*
about error process
*/
#include
#include
#include
/*
if debuging use #define ERROR_DEBUG
otherwise remove it.
*/
//#define ERROR_DEBUG
#ifdef
ERROR_DEBUG
#define error(x) error_debug(x)
#define report() report_debug()
#define initerror() initerror_debug()
char *err[10];
int errs=0;
void initerror_debug(){
int i;
for(i=0;i<10;i++)err[i]=NULL;
}
void error_debug(char *a){
if(errs>9)return;
err[errs]=(char *)malloc(strlen(a)+1);
strcpy(err[errs],a);
printf(a);
errs++;
}
void report_debug(){
int i;
if(!errs)return;
for(i=0;i printf(err[i]);