欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    汉诺塔的非递归演示动画Word下载.docx

    • 资源ID:8122695       资源大小:16.55KB        全文页数:7页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    汉诺塔的非递归演示动画Word下载.docx

    1、void error_debug(char *a) if(errs9)return; errerrs=(char *)malloc(strlen(a)+1); strcpy(errerrs,a); printf(a); errs+;void report_debug() if(!errs)return;errs;i+) printf(erri); free(erri); #else #define error(x) #define report() #define initerror()#endif about stack#define STACK_SIZE 31typedef struct

    2、int dataSTACK_SIZE; int top;stack;int clear(stack *a);int create(stack *a);int push(stack *a,int data);int pop(stack *a,int *data);int gettop(stack *a,int *data);int dispose(stack *a);int pop(stack *a,int *data) if(a-top) *data=a-data-a-top; return 1; else error(pop(stack *,int *):stack empty!n); re

    3、turn 0;int push(stack *a,int data)topdataa-top+=data; else push(stack *,int):stack full!int create(stack *a) *a=(stack *)malloc(sizeof(stack); if(*a)return clear(*a); elsecreate(stack *):create error! Not enough momery!int clear(stack *a) if(a)top=0;clear(stack *):stack not exist!int gettop(stack *a

    4、,int *data)top-1;gettop(stack *,int *):int dispose(stack *a) free(a);dispose(stack *):/*/ about Hanoi the gamegraphics.hdos.h#define MAX_LEVEL STACK_SIZEint positionMAX_LEVEL+1;stack *theStack3;int depth;int mode;int print;int initgame(int d) int x,y; int h=5; int w; initerror(); if(mode) int gdrive

    5、r = DETECT, gmode, errorcode; /* initialize graphics mode */ initgraph(&gdriver, &gmode, setfillstyle(1,7);3;i+)create(&theStacki) break; if(i!=3) for(;i=0;i-)dispose(theStacki);initgame(int):can not init stack! depth=d; for(i=d;i;i-) push(theStack0,i); y=200+100-theStack0-top*(h+1); w=i*10; x=150-w

    6、/2; setcolor(i); setfillstyle(1,i); bar(x,y,x+w,y+h); positioni=0; setcolor(15); rectangle(150+i*150-1,120,150+i*150+1,300); line(50,300,500,300);int endgame() int i=2; printf(report: report(); if(mode)closegraph();void show(int p,int from,int to) int newx,newy; int w=p*10; y=200+100-(theStackfrom-t

    7、op+1)*(h+1); x=from*150+150-w/2; newx=to*150+150-w/2; newy=200+100-theStackto- while(y100) setcolor(0); setfillstyle(1,0); y-=(h+1); rectangle(150+from*150-1,120,150+from*150+1,300); setcolor(p); setfillstyle(1,p); delay(10); while(x!=newx) (xnewx)?x-:x+; delay(2); while(y,&t)move(int):the stack is

    8、emptyn if(t=p) pop(theStackpositionpt);mode&print)printf(%c - ,A+positionp); /* another important core line */ s=(positionp+1+(depth%2?p%2:(p+1)%2) )%3; if(gettop(theStacks,&t)&t+positionp,conio.hvoid main() unsigned long i; unsigned long N=10; unsigned long p,q;Welcome to HanoinNote that this Hanoi

    9、 is not write by recurrence!And not calculate with any stack.nbut i want to check if the a is right.ni use 3 stack to show if there is any violent move happens.:)nnEnter a number as level(1 to 30): scanf(%dN); if(N30)error: not 1 to 30n return;n Select show mode(c in TEXT g in GRAPHICS)nNote that if

    10、 the level is to big youd better not use for speed.n19 is about 20 seconds. 20 is about double of that. etc.nI test on a intel 166mmx cpu. 30 may be 40*1024 seconds.nwish you succeed! switch(getch() case :do you want to show the result?(y/n)nprint result will be slow! do mode=getch(); if(mode=y)print=1;n)print=0; while(mode!=mode! mode=0;mode=1;break; default:printf( neither nor return;processing.n initgame(N); /* core here! only 8 lines, ha! here get the level queue as 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 */ for(i=1;(1L q=1L=1; p-; if(mode|print)move(p); else move2(p);okn getch(); endgame();


    注意事项

    本文(汉诺塔的非递归演示动画Word下载.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开