没有合适的资源?快使用搜索试试~ 我知道了~
数据结构课程设计-旅游景点咨询系统的设计与实现.docx
0 下载量 23 浏览量
2023-07-02
13:42:17
上传
评论
收藏 100KB DOCX 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/87983090/0001-35bf0bfa0fcb54cdfc088941223b42d2_thumbnail-wide.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
21页
数据结构课程设计-旅游景点咨询系统的设计与实现.docx
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/release/download_crawler_static/87983090/bg1.jpg)
2017ban
![](https://csdnimg.cn/release/download_crawler_static/87983090/bg2.jpg)
一、需求分析
1、问题描述
创建一个至少有 15 个点的无向网表示的某个旅游景点的导游图。顶
点代表景点,类型为字符串(例如,泰山导游图:“天地广场门”,“十
八盘”,“冯玉祥墓”,“桃花峪门”,“中天门”,“南天门”,“玉皇顶”
等),弧表示两个景点之间可以直达,弧上的权值表示两个景点之间
的路程(公里数),弧上还有到达方法的信息(有步行和索道两种)。
建立一个游客咨询系统。
2、基本要求
a. 创建图的存储结构。
b. 输入两个景点名,就可以得到从一个景点到达另一个景点的所有
简单路径、相应路径的路程公里数、行走的方法(每一段是步行,还
是坐索道)。
c. 输入两个景点名,就可以得到其最短路径,即:路程最短的行进
方法;如果两者无路径可通,就得出“两景点不可达的信息”。
二、概要设计
1.数据结构
本程序需要用到两个结构体,分别为 ArcCell 和 MGraph。
2.程序模块
本程序包含两个模块,一个是实现功能的函数的模块,另一个是主函
数模块。
![](https://csdnimg.cn/release/download_crawler_static/87983090/bg3.jpg)
系统子程序及功能设计
本系统共有七个子程序,分别是:
int LocateVex(MGraph G,VertexType u)//得到顶点 u 的序号
void CreateDN(MGraph *G)//建立景点间的无向网
VertexType* GetVex(MGraph G,int v)//根据顶点序号返回顶点值
int FirstAdjVex(MGraph G,VertexType v)// 返回 v 的第一个邻接顶点的
序号
int NextAdjVex(MGraph G,VertexType v,VertexType w)// 返回 v 的(相对
于 w 的)下一个邻接顶点的序号
void Simpleway(MGraph& m,char *str,char *buf)//求任意两个景点之
间的所有简单路径
int Minway(MGraph& m,char *str,char *buf)//求两顶点间的最短路径
3. 各模块之间的调用关系以及算法设计
函数 CreateDN 调用函数 LocateVex
函数 Simpleway 调用函数 LocateVex
函数 Minway 调用函数 LocateVex, GetVex,FirstAdjVex,NextAdjVex
主函数调用函数 CreateDN,Simpleway,Minway。
三、详细设计
1.数据类型定义
typedef struct
{
VRType adj;
int info;
![](https://csdnimg.cn/release/download_crawler_static/87983090/bg4.jpg)
}ArcCell,AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];
typedef struct
{
VertexType vexs[MAX_VERTEX_NUM];
AdjMatrix arcs;
int vexnum,arcnum;
}MGraph;
2.系统主要子程序详细设计
a.
void CreateDN(MGraph *G)
{ /* 采用数组(邻接矩阵)表示法,构造有向网 G */
int i,j,k,w,c;
char s[MAX_INFO],*info;
VertexType va,vb;
printf("请输入景点个数以及景点间所有路径的个数(以空格隔开)");
scanf("%d %d",&(*G).vexnum,&(*G).arcnum);
printf("请输入%d 个景点:\n",(*G).vexnum);
for(i=0;i<(*G).vexnum;++i) /* 构造顶点向量 */
scanf("%s",(*G).vexs[i]);
for(i=0;i<(*G).vexnum;++i) /* 初始化邻接矩阵 */
for(j=0;j<(*G).vexnum;++j)
{
(*G).arcs[i][j].adj=INFINITY; /* 网 */
(*G).arcs[i][j].info=NULL;
}
printf("请输入%d 条景点间的路径,路径间的路程权值以及路径间到达方式(以
0 或 1 来表示到达方式,步行:0,索道:1,如:光明顶 迎客松 30 1): \n",(*G).arcnum);
for(k=0;k<(*G).arcnum;++k)
{
scanf("%s%s%d%d*c",va,vb,&w,&c);/* %*c 吃掉回车符 */
i=LocateVex(*G,va);
j=LocateVex(*G,vb);
(*G).arcs[i][j].adj=(*G).arcs[j][i].adj=w; /* 有向网 */
(*G).arcs[i][j].info=(*G).arcs[j][i].info=c; /* 有向 */
}
}
b.
void Simpleway(MGraph& m,char *str,char *buf)/*求任意两个景点之间的所有简
单路径*/
{
![](https://csdnimg.cn/release/download_crawler_static/87983090/bg5.jpg)
for(int i=0;i<m.vexnum;i++)
{
visited[i]=false;
}
int x=LocateVex(m,str);
int y=LocateVex(m,buf);
/*从 x 出发到 y*/
stack<int>s;
s.push(x);
visited[x]=true;
int i=0;
int z=0;//表示没有找到这两个点之间有路径
while(!s.empty())
{
int flag=0;
//取栈顶元素
int t=s.top();
for(;i<m.vexnum;i++)
{
if(m.arcs[t][i].adj != INFINITY && visited[i]==false)
{
s.push(i);
flag=1;
visited[i]=true;
/*找到简单路径*/
if(s.top()==y)//到达终点
{
z=1;//找到这样的路径
cout<<"一条简单路径为:"<<endl;
{
stack<int>s2;//建立一个临时的栈
//创建一个数组存放路径下标
int *way=new int[s.size()];
int count=0;
while(!s.empty())
{
s2.push(s.top());
s.pop();
}
//还原 s 同时输出路径
while(!s2.empty())
{
剩余20页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
matlab大师
- 粉丝: 2501
- 资源: 8万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)