数据结构课程设计迷宫

数据结构课程设计迷宫

ID:23374331

大小:276.00 KB

页数:11页

时间:2018-11-06

数据结构课程设计迷宫_第1页
数据结构课程设计迷宫_第2页
数据结构课程设计迷宫_第3页
数据结构课程设计迷宫_第4页
数据结构课程设计迷宫_第5页
资源描述:

《数据结构课程设计迷宫》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、课程设计报告数据结构课程设计报告设计题目:迷宫年级计科09级班级092,093姓名学号指导教师起止时间2011.12.92011年第2学期五.C语言源代码#include#include#includeintm,n;int**maze=NULL;structElement{inti;intj;intdi;};typedefstructLinkStack{structElementelement;structLinkStack*next;structLinkStack*prior;}LinkS

2、tack;LinkStack*top=NULL;LinkStack*head=NULL;intcount=0;intmgpath(intxi,intyi,intxe,intye);voidprintMaze(int**maze){inti,j;printf("您的迷宫图如下所示:");for(i=0;i

3、all(int**maze){inti,j;for(i=0;i0&&i<(m+2-1)){maze[i][0]=1;maze[i][n+2-1]=1;break;}if(i==m+2-1){maze[i][j]=1;}}}}int**initMaze(){inti,j;intflag=0;printf("请输入迷宫的行数m=");scanf("%d",&m);printf("请输入迷宫的列数n=");scanf("%d",&n);maz

4、e=(int**)malloc(sizeof(int*)*(m+2));printf("*****************************************");for(i=0;i

5、%d",&maze[i][j]);}}printf("***************************************");printMaze(maze);returnmaze;}voidmazePath(){if(top==head&&head!=NULL){return;}while(top!=head

6、

7、head==NULL){intk=0;intfind=0;inti=0,j=0;intdi=-1;if(top!=NULL)di=top->element.di;LinkStack*node=(LinkStack*)ma

8、lloc(sizeof(LinkStack));node->element.di=di;if(top==NULL){head=(LinkStack*)malloc(sizeof(LinkStack));head->element.i=1;head->element.j=0;head->element.di=1;head->prior=NULL;top=head;node->element.i=1;node->element.j=1;node->element.di=-1;}top->next=node;node->next=NULL;node->p

9、rior=top;top=node;di=top->element.di;while(di<4&&find==0){di++;switch(di){case0:i=top->prior->element.i-1;j=top->prior->element.j;break;case1:i=top->prior->element.i;j=top->prior->element.j+1;break;case2:i=top->prior->element.i+1;j=top->prior->element.j;break;case3:i=top->prio

10、r->element.i;j=top->prior->element.j-1;break;}if(maze[i][j]==

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

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

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