数据结构公园导游Word格式文档下载.docx
- 文档编号:13333168
- 上传时间:2022-10-09
- 格式:DOCX
- 页数:18
- 大小:72.50KB
数据结构公园导游Word格式文档下载.docx
《数据结构公园导游Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《数据结构公园导游Word格式文档下载.docx(18页珍藏版)》请在冰豆网上搜索。
图1-6
5.小结
数据结构书中的迪杰斯特拉算法只能求出最短路径中有哪个景点,但无法求出这几个景点的经过顺序,所以先利用迪杰斯特拉算法记录下某个顶点求出到最短路径的顺序,然后再比对哪几个景点是最短路径里所经过的得出最短路径及景点路过的顺序。
6、参考文献
[1]严蔚敏,吴伟民编著.数据结构(C语言版)--北京:
清华大学出版社,2007.2
[2]严蔚敏,吴伟民米宁编著.数据结构题集(C语言版)--北京:
清华大学出版社,2007.3
[3]网上搜索相关程序作为参考
附录:
#defineInfinity1000
#defineMaxVertexNum35
#defineMAX40
#include<
stdio.h>
stdlib.h>
conio.h>
string.h>
iostream>
usingnamespacestd;
typedefstructarcell//边的权值信息
{
intadj;
//权值
}arcell,adjmatrix[MaxVertexNum][MaxVertexNum];
//图的邻接矩阵类型
typedefstructvexsinfo//顶点信息
intposition;
//景点的编号
charname[32];
//景点的名称
charintroduction[256];
//景点的介绍
}vexsinfo;
typedefstructmgraph//图结构信息
vexsinfovexs[MaxVertexNum];
//顶点向量(数组)
adjmatrixarcs;
//邻接矩阵
intvexnum,arcnum;
//分别指定顶点数和边数
}mgraph;
//全局变量
intvisited[35];
//用于标志是否已经访问过
intd[35];
//用于存放权值或存储路径顶点编号
mgraphcampus;
//图变量(大公园园)
//
(1)对图初始化
mgraphinitgraph()
inti=0,j=0;
mgraphc;
c.vexnum=28;
//顶点个数
c.arcnum=39;
//边的个数
for(i=0;
i<
c.vexnum;
i++)//依次设置顶点编号
c.vexs[i].position=i;
//依次输入顶点信息
strcpy(c.vexs[0].name,"
小西南门"
);
strcpy(c.vexs[0].introduction,"
离公交站近"
strcpy(c.vexs[1].name,"
公园南正门"
strcpy(c.vexs[1].introduction,"
公园大门、公园班车进出口"
strcpy(c.vexs[2].name,"
东坡亭"
strcpy(c.vexs[2].introduction,"
东坡亭,亭高3层"
strcpy(c.vexs[3].name,"
西施坡"
strcpy(c.vexs[3].introduction,"
西施坡,风光优美"
strcpy(c.vexs[4].name,"
黄蓉亭"
strcpy(c.vexs[4].introduction,"
黄蓉亭,名字来自于射雕英雄传"
strcpy(c.vexs[5].name,"
荷花塘"
strcpy(c.vexs[5].introduction,"
荷花塘,里面有很多荷花"
strcpy(c.vexs[6].name,"
广场"
strcpy(c.vexs[6].introduction,"
很大的一块空地"
strcpy(c.vexs[7].name,"
花坛"
strcpy(c.vexs[7].introduction,"
里面有很多花"
strcpy(c.vexs[8].name,"
长椅"
strcpy(c.vexs[8].introduction,"
这儿有很多椅子,有人可以做"
strcpy(c.vexs[9].name,"
慈悲庵"
strcpy(c.vexs[9].introduction,"
慈悲庵,慈悲庵是创建于元代的古刹"
strcpy(c.vexs[10].name,"
云绘楼"
strcpy(c.vexs[10].introduction,"
云绘楼是一座皇家园林建筑"
strcpy(c.vexs[11].name,"
九龙壁"
strcpy(c.vexs[11].introduction,"
整壁用彩色琉璃瓦镶砌而成"
strcpy(c.vexs[12].name,"
白塔"
strcpy(c.vexs[12].introduction,"
白塔,高5层"
strcpy(c.vexs[13].name,"
游泳馆"
strcpy(c.vexs[13].introduction,"
室内小型游泳馆"
strcpy(c.vexs[14].name,"
彩虹桥"
strcpy(c.vexs[14].introduction,"
彩虹桥,桥上有彩虹灯"
strcpy(c.vexs[15].name,"
小木桥"
strcpy(c.vexs[15].introduction,"
小木桥,环境优雅"
strcpy(c.vexs[16].name,"
沙滩"
strcpy(c.vexs[16].introduction,"
河边的沙滩"
strcpy(c.vexs[17].name,"
奇石"
strcpy(c.vexs[17].introduction,"
奇石大石头"
strcpy(c.vexs[18].name,"
超市"
strcpy(c.vexs[18].introduction,"
strcpy(c.vexs[19].name,"
欧阳亭"
strcpy(c.vexs[19].introduction,"
亭高3楼"
strcpy(c.vexs[20].name,"
明光塔"
strcpy(c.vexs[20].introduction,"
明光塔"
strcpy(c.vexs[21].name,"
雷峰塔"
strcpy(c.vexs[21].introduction,"
雷锋塔"
strcpy(c.vexs[22].name,"
洞庭湖"
strcpy(c.vexs[22].introduction,"
洞庭湖"
strcpy(c.vexs[23].name,"
苏提"
strcpy(c.vexs[23].introduction,"
苏提"
strcpy(c.vexs[24].name,"
灯塔"
strcpy(c.vexs[24].introduction,"
strcpy(c.vexs[25].name,"
"
strcpy(c.vexs[25].introduction,"
strcpy(c.vexs[26].name,"
树林"
strcpy(c.vexs[26].introduction,"
有很多树"
strcpy(c.vexs[27].name,"
strcpy(c.vexs[27].introduction,"
//依次输入边上的权值信息
i++)
for(j=0;
j<
j++)
c.arcs[i][j].adj=Infinity;
//先初始化图的邻接矩阵
//部分弧长
c.arcs[0][2].adj=50;
c.arcs[0][3].adj=60;
c.arcs[1][4].adj=90;
c.arcs[2][3].adj=60;
c.arcs[2][8].adj=40;
c.arcs[3][4].adj=60;
c.arcs[3][6].adj=40;
c.arcs[4][5].adj=70;
c.arcs[4][9].adj=70;
c.arcs[4][10].adj=80;
c.arcs[4][17].adj=200;
c.arcs[5][7].adj=70;
c.arcs[6][9].adj=40;
c.arcs[7][18].adj=190;
c.arcs[8][11].adj=50;
c.arcs[9][12].adj=40;
c.arcs[10][18].adj=70;
c.arcs[11][12].adj=60;
c.arcs[11][14].adj=50;
c.arcs[11][15].adj=50;
c.arcs[12][16].adj=50;
c.arcs[13][14].adj=40;
c.arcs[13][22].adj=60;
c.arcs[14][15].adj=50;
c.arcs[14][20].adj=90;
c.arcs[15][16].adj=60;
c.arcs[15][21].adj=40;
c.arcs[16][17].adj=60;
c.arcs[17][18].adj=80;
c.arcs[18][19].adj=60;
c.arcs[20][21].adj=60;
c.arcs[20][24].adj=80;
c.arcs[22][23].adj=60;
c.arcs[22][25].adj=80;
c.arcs[23][24].adj=60;
c.arcs[24][26].adj=100;
c.arcs[24][27].adj=100;
c.arcs[25][26].adj=90;
c.arcs[26][27].adj=90;
i++)//邻接矩阵是对称矩阵,对称赋值
c.ar
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据结构 公园 导游