校园导航系统源代码Word下载.docx
- 文档编号:6860351
- 上传时间:2023-05-07
- 格式:DOCX
- 页数:12
- 大小:17.21KB
校园导航系统源代码Word下载.docx
《校园导航系统源代码Word下载.docx》由会员分享,可在线阅读,更多相关《校园导航系统源代码Word下载.docx(12页珍藏版)》请在冰点文库上搜索。
voidShortestPath_DIJ(MGraph*G);
voidSearch(MGraph*G);
intLocateVex(MGraph*G,char*v);
/**********主函数************************/
voidmain(void)
system("
color5f"
);
/*修改控制台的颜色信息,改为白字蓝底的模式*/
modecon:
cols=140lines=130"
/*设置批处理运行时窗口大小的*/
cmd();
}
/********自定义函数***************/
/*cmd函数(根据目录选择要进展的项目)*/
voidcmd(void)
chark;
b=InitGraph();
show1();
Menu();
while
(1)
scanf("
\n%c"
&
k);
switch(k)
case'
x'
:
system("
cls"
show1();
Menu();
list();
ShortestPath_DIJ(&
b);
printf("
---------------------------------欢送您的使用--------------------------------\n"
\n请您继续选择效劳:
"
break;
y'
Search(&
z'
printf("
┏━━━━━━━━━━━━━━━━━━━━┓\n"
┃感使用┃\n"
┃建筑术大学┃\n"
┃智能导航系统┃\n"
┗━━━━━━━━━━━━━━━━━━━━┛\n"
exit(0);
default:
输入信息错误!
\n请输入x或y或z.\n"
}}
/*迪杰斯特拉算法来计算出起点到各个顶点之间的最短路径,v0为起点*/
voidShortestPath_DIJ(MGraph*G)
intv,w,i,min,t=0,x,flag=1,v0,v1,have[100],k;
intfinal[20],D[20],p[23][23];
while(flag)
请输入起始景点编号:
\n"
scanf("
%d"
v0);
if(v0<
0||v0>
G->
vexnum)
景点编号不存在!
请输入终止景点编号:
v1);
if(v1<
0||v1>
if(v0>
=0&
&
v0<
vexnum&
v1>
v1<
vexnum)
flag=0;
for(v=0;
v<
vexnum;
++v)
final[v]=0;
D[v]=G->
arcs[v0][v].adj;
for(w=0;
w<
++w)
p[v][w]=INFINITY;
if(D[v]<
INFINITY)
p[v][v0]=1;
p[v][v]=1;
D[v0]=0;
final[v0]=1;
have[0]=v0;
for(i=1;
i<
++i)
min=INFINITY;
if(!
final[w])
if(D[w]<
min)
v=w;
min=D[w];
final[v]=1;
have[k]=v;
k++;
final[w]&
((min+(G->
arcs[v][w].adj))<
D[w]))
D[w]=min+G->
arcs[v][w].adj;
for(x=0;
x<
x++)
p[w][x]=p[v][x];
p[w][w]=1;
for(i=0;
i++)
if(p[v1][have[i]]==1){
-->
%s"
G->
vexs[have[i]].name);
if((v1-v0)==1)printf("
\n路径长度:
%d\n"
arcs[v0][v1]);
elseprintf("
D[v1]);
}//ShortestPath_DIJend
/*查找函数的建立*/
voidSearch(MGraph*G)
intk,flag=1;
请输入要查询的景点编号:
if(k<
0||k>
请重新输入景点编号:
if(k>
k<
┏━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n"
┃编号┃景点名称┃简介┃\n"
┃%-4d┃%-16s┃%-58s┃\n"
vexs[k].num,G->
vexs[k].name,G->
vexs[k].introduction);
┗━━┻━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"
}//Searchend
voidshow1()
{printf("
\t\t★★欢送使用建筑大学智能导航系统★★\n"
\t\t\t建筑大学南校区简单版平面图\n\n"
\t学校北门\n"
\t┃\n"
\t┏━━北食堂━━━━━━━━━宿舍楼1\n"
\t┃┃\n"
\t┃宿舍楼2\n"
\t┃━━━━━━九月桥━━━━━┃\n"
\t主教楼┃\n"
\t日月广场┃\n"
\t图书馆┃\n"
\t还在建┃\n"
\t南食堂━━━━━━━━━━━━宿舍楼15\n"
\t━━━━━━━━━━━━━━南苑超市\n"
voidlist()
学校景点列表:
0:
学校北门"
1:
宿舍楼1"
2:
宿舍楼2"
3:
宿舍楼15"
4:
九月桥\n"
5:
主教楼"
6:
图书馆"
7:
日月广场"
8:
体育场\n"
9:
还在建"
10:
南食堂"
/*目录函数的构建*/
voidMenu()
\n建筑大学南校区导游图\n"
┃x.选择出发点和目的地┃\n"
┃y.查看景点信息┃\n"
┃z.退出系统┃\n"
请选择效劳"
/*MGraph函数〔图的构建〕*/
MGraphInitGraph(void)
MGraphG;
inti,j;
G.vexnum=17;
//顶点是17个
G.arcnum=25;
//弧线有25个
G.vexnum;
i++)
G.vexs[i].num=i;
strcpy(G.vexs[0].name,"
strcpy(G.vexs[0].introduction,"
学校的正门,气势宏伟"
strcpy(G.vexs[1].name,"
宿舍楼1"
strcpy(G.vexs[1].introduction,"
睡觉的地方"
strcpy(G.vexs[2].name,"
宿舍楼2"
strcpy(G.vexs[2].introduction,"
strcpy(G.vexs[3].name,"
宿舍楼15"
strcpy(G.vexs[3].introduction,"
,,,,,,,,"
strcpy(G.vexs[4].name,"
九月桥"
strcpy(G.vexs[4].introduction,"
连接生活区和教学区的桥。
strcpy(G.vexs[5].name,"
主教楼"
strcpy(G.vexs[5].introduction,"
教学,开会"
strcpy(G.vexs[6].name,"
图书馆"
strcpy(G.vexs[6].introduction,"
安静当学霸的地方"
strcpy(G.vexs[7].name,"
日月广场"
strcpy(G.vexs[7].introduction,"
有漂亮喷泉的广场"
strcpy(G.vexs[8].name,"
体育场"
strcpy(G.vexs[8].introduction,"
运动健身的地方"
strcpy(G.vexs[9].name,"
strcpy(G.vexs[9].introduction,"
学校新修的实验楼,灰常高大上"
strcpy(G.vexs[10].name,"
南食堂"
strcpy(G.vexs[10].introduction,"
不好吃"
for(j=0;
j<
j++)
G.arcs[i][j].adj=INFINITY;
G.arcs[0][1].adj=50;
G.arcs[1][2].adj=15;
G.arcs[1][3].adj=40;
G.arcs[2][3].adj=30;
G.arcs[0][3].adj=90;
G.arcs[3][4].adj=30;
G.arcs[4][9].adj=1000;
G.arcs[4][5].adj=20;
G.arcs[5][6].adj=10;
G.arcs[6][7].adj=8;
G.arcs[6][8].adj=12;
G.arcs[7][8].adj=7;
G.arcs[0][9].adj=30;
G.arcs[9][10].adj=500;
G.arcs[10][11].adj=25;
G.arcs[11][12].adj=8;
G.arcs[12][13].adj=5;
G.arcs[13][14].adj=10;
G.arcs[12][14].adj=10;
G.arcs[14][15].adj=150;
G.arcs[15][16].adj=3;
G.arcs[5][15].adj=150;
G.arcs[4][15].adj=30;
G.arcs[1][11].adj=300;
G.arcs[8][14].adj=40;
G.arcs[j][i].adj=G.arcs[i][j].adj;
returnG;
}//InitGraphend
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 校园 导航系统 源代码