下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上#include<iostream>#include<iomanip>using namespace std;struct Positionint row;int col;struct TEAMint x;int y;TEAM *next;Position start,end,path100;TEAM *team_l=NULL;int a100100;int m,n,path_len;void Output()int i,j;cout<<"n-布线区域图-n"for(i=0;i<m+2;i+)for(j=0
2、;j<n+2;j+)cout<<setw(2)<<aij;cout<<endl;cout<<"-n"return;void Input_data()char yes;int x,y;cout<<"请输入区域大小(行列的个数): "cin>>m>>n;cout<<"请输入开始点坐标(x,y): "cin>>start.row>>start.col;cout<<"请输入结束点坐标(x,y):
3、"cin>>end.row>>end.col;cout<<"区域内是否有被占用点? (y/n) "cin>>yes;while(yes='y')cout<<"请输入占用点的坐标(x,y): "cin>>x>>y;if(x<0 | x>m+1 | y<0 | y>n+1 | (x=start.row && y=start.col) | (x=end.row && y=end.col) cout
4、<<"输入错误,请重新输入!n"continue;elseaxy=-1;cout<<"是否还有被占用点? (y/n) "cin>>yes;for(x=0;x<m+2;x+)a0x=-1;am+1x=-1;for(x=0;x<n+2;x+)ax0=-1;axn+1=-1;return;void Inq(Position p)TEAM *t,*q;q=team_l;t=new TEAM;t->x=p.row;t->y=p.col;t->next=NULL;if(team_l=NULL)team
5、_l=t;return ;while(q->next!=NULL)q=q->next;q->next=t;return;Position outq()Position out;out.row=team_l->x;out.col=team_l->y;team_l=team_l->next;return out;void Find_path()Position offset4;Position here=start.row,start.col;Position nbr=0,0;int num_of_nbrs=4;int i,j;offset0.row=0;off
6、set0.col=1; /右offset1.row=1;offset1.col=0; /下offset2.row=0;offset2.col=-1;/左offset3.row=-1;offset3.col=0;/上if(start.row = end.row)&&(start.col = end.col)path_len = 0;return;while(1)for(i=0;i<num_of_nbrs;i+)nbr.row=here.row+offseti.row;nbr.col=here.col+offseti.col;if(anbr.rownbr.col=0)anbr
7、.rownbr.col=ahere.rowhere.col + 1;if(nbr.row = end.row) && (nbr.col = end.col)break;Inq(nbr); /nbr入队if(nbr.row = end.row) && (nbr.col = end.col)/是否到达目标位置finishbreak;if(team_l=NULL)/或节点队列是否为空 cout<<"n没有结果!n"return ;here=outq();path_len=aend.rowend.col;here=end;for(j=pa
8、th_len-1;j>=0;j-)/往回找路径pathj = here;for(i = 0;i < num_of_nbrs;i+)nbr.row = here.row + offseti.row;nbr.col = here.col + offseti.col;if(anbr.rownbr.col = j) break;here=nbr;return;void Out_path()int i;cout<<"n路径为:"cout<<"("<<start.row<<","<<start.col<<")"for(i=0;i<path_len;i+)cout<<"("<<pathi.row<<","<
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 大观念视域下的高中英语单元整体教学设计
- 宝鸡文理学院《生态学概论》2021-2022学年第一学期期末试卷
- 课题2 水的组成(第1课时)九年级化学上册课件(人教版2024)
- 主变压器温度计相关知识讲解
- 户外使用的便携式烹饪套具相关项目实施方案
- 事业单位考试大纲考点特训《公文写作与处理》(2023年版)-3
- 宝鸡文理学院《钢笔书法训练》2023-2024学年第一学期期末试卷
- 喷漆枪相关项目实施方案
- 家用非电烹饪加热器相关项目实施方案
- 最易忽视的颈肩痛:肩胛背神经卡压综合征治疗动作
- 部编版《aieiui》(完美版)课件
- 2022人力资源管理考试题库及答案解析
- 基于智慧课堂的初中英语阅读教学
- 瓦斯抽采方法及钻场孔布置课件
- 标准DBS54 2002-2017 食品安全地方标准 糌粑制作规范
- (新版)汽车底盘构造与维修(全套319张课件)
- 《乡土中国》第4章《差序格局》-统编版高中语文必修上册
- 《创新方法TRIZ理论入门》课件-第3章-功能分析
- 殷长军CTA指导下腹腔镜肾部分切除术课件
- 冷库报价表格
- 奖状证书模板优秀员工2
评论
0/150
提交评论