迷宫求解问题(maze problem solving)

迷宫求解问题(maze problem solving)

ID:16167057

大小:18.54 KB

页数:12页

时间:2018-08-08

迷宫求解问题(maze problem solving)_第1页
迷宫求解问题(maze problem solving)_第2页
迷宫求解问题(maze problem solving)_第3页
迷宫求解问题(maze problem solving)_第4页
迷宫求解问题(maze problem solving)_第5页
资源描述:

《迷宫求解问题(maze problem solving)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、迷宫求解问题(Mazeproblemsolving)#includesmalloc.h><#includesstdio.h><#includesconio.h><#definem6/*规定迷宫的行数*/#definen4/*规定迷宫的列数*/inti=0;typedefstructshuju{intdate;intflag;/*判断这个位置是否被走过,使其产生记忆效果*/}shu;typedefstructmaze"intc;intflag;intdirect;intx;inty;structmaze*next;}mg;mg*top,*p;mg*po

2、p(intbb,intxx,intyy,shut[m][n])/*入栈操作*/{intp,j2;the++;p=(mg)malloc(sizeof(mg));p->c=bb.p->flag=1;p->direct=4;p->x=xx;p->y=yy;if(i==1)(top=p;top->next=null;}else{p->next=top;top=p;}clrscr();for(p=0;0

3、rintf("%3d,"t[i2][j2]date);}else{textcolor(white);cprintf("%3d,"t[i2][j2]date);}}for(p=0;p<80;(2++)/*时间延迟*/delay(1000).}intway(intx1,intyl,shus[m][n])/*寻找路径函数*/{intx,y,f=0.intc,total.while(top!/*以下是在四个方向上进行判断=null)通就入栈,不通就进行下个方向的判断,如果四个方向都不通,就出栈*/if(top->flag==1){x=top->x;y=top

4、->y;if(x==x1&y==yl){f=1;break;判断右方向}/**/if(top->direct==4)(top)direct--;if(0<=y+1&&y+1direct==3)/*判断下方向*/(top)direct--;if(0<=x+1&&x+1

5、)pop(d[x+1][y]date=8,x+1,y,d);}elseif(top->direct==2)/*判断左方向*/(top)direct--;if(0<=y-1&&y-1direct==1)/*判断上方向*/(top)direct--;top->flag=0;if(0<=x-1&x1

6、x-1][y]date=8x1,y,d);}}else{d[x][toptop->->y]date=0;d[top->x>y-][top].flag=1;top=top->next;clrscr();for(p=0;p

7、/*产生时间延迟,不同的cpu产生的延迟效果不一样*/delay(1000);}returnf;}main(){shus[m][n];intx,y,x1,y1;inti1,j1,i,j,f;for(i=0;0

8、inkamigong--0isyes--1isno");for(i=0;0

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。