完美升级版校园导航系统数据结构毕业论文报告书.docx

上传人:b****3 文档编号:5274233 上传时间:2022-12-14 格式:DOCX 页数:21 大小:35.50KB
下载 相关 举报
完美升级版校园导航系统数据结构毕业论文报告书.docx_第1页
第1页 / 共21页
完美升级版校园导航系统数据结构毕业论文报告书.docx_第2页
第2页 / 共21页
完美升级版校园导航系统数据结构毕业论文报告书.docx_第3页
第3页 / 共21页
完美升级版校园导航系统数据结构毕业论文报告书.docx_第4页
第4页 / 共21页
完美升级版校园导航系统数据结构毕业论文报告书.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

完美升级版校园导航系统数据结构毕业论文报告书.docx

《完美升级版校园导航系统数据结构毕业论文报告书.docx》由会员分享,可在线阅读,更多相关《完美升级版校园导航系统数据结构毕业论文报告书.docx(21页珍藏版)》请在冰豆网上搜索。

完美升级版校园导航系统数据结构毕业论文报告书.docx

完美升级版校园导航系统数据结构毕业论文报告书

 

课程设计报告书

 

课程名称数据结构

设计题目校园导航系统

专业班级计算机11-4班

目录

1.设计时间………………………………………………2

2.设计目的………………………………………………2

3.设计任务………………………………………………2

4.设计内容………………………………………………2

4.1需求分析…………………………………………………2

4.2总体设计…………………………………………………3

4.3详细设计…………………………………………………4

4.4测试与分析………………………………………………12

4.4.1测试…………………………………………………………12

4.4.2分析…………………………………………………………13

4.5附录………………………………………………………14

5总结与展望……………………………………………20

6.参考文献………………………………………………21

7.成绩评定………………………………………………21

 

1设计时间

2013年12月3日

2设计目的

1.加深对《数据结构》这一课程所学内容的进一步理解与巩固

2.通过完成课程设计,逐渐培养自己的编程能力;

3.培养给出题目后,构建框架,用计算机解决的能力;

4.通过调试程序积累调试C程序设计的经验;

3设计任务

给出校园各主要建筑的名称信息及有线路联通的建筑之间的距离,利用校园导航系统计算出给定的起点到终点之间的最近距离及线路。

4设计内容

4.1需求分析

1.程序所能达到的功能:

(1)map——输出山东科技大学平面图。

(2)init()——按相应编号输入各个节点内容,对相应路径赋值的函数。

(3)floyd()----弗洛伊德求最短路径

(4)information()——输出简介的函数

(5)Path()——最短路径的输出函数

(6)shortestpath()——调用弗洛伊德和最短路径输出的函数

(7)main()——主函数

2.输入的形式和输入值的范围:

输入数字和字母:

字母:

以s查询最短路径;以i查询信息;以e退出程序。

数字:

从1到9输入。

3.输出的形式:

从A到B得最短路径为:

A-到-C-到-D-到-B

最短距离为:

xxx米。

4.测试数据包括在正确的输入及输出结果及含有错误的输入及输出结果:

Input:

s

Output:

Pleaseenterthenumbertwotoquery:

17

Output:

TheshortestpathfromAreaCdormitorybuildingtolibraryis:

AreaCdormitorybuilding--AreaCrestaurant--library;

Theshortestdistanceis:

150meters.

Input:

i

Output:

Pleaseenterthenumberofquerysite:

3

Output:

@name:

AreaBdormitorybuilding

@introduction:

AreaBstudentrestarea

input:

e

output:

Thankyouforyouuse

4.2总体设计

1.抽象数据类型定义

typedefstruct

{

charname[100];

intnumber;

charintroduce[100];

}Vertex;

2.主程序模块的整体流程

1、进入主函数,调用init(),map()。

2、选择“s”,调用shortestpath函数,并同时调用floyd和way函数。

3、选择“i”,调用information函数

4、选择“e”,退出。

3.各模块调用关系如下:

4.3详细设计

1.有向网节点结构体类型定义:

typedefstruct

{

charname[100];

intnumber;

charintroduce[100];

}Vertex;

2.主程序和其它主要函数伪码算法

1)主程序

intmain()

{

chari;

printf("Welcometousetheshandonguniversityofscienceandtechnologyofnavigationsystem\n\n\n\n");

init();

map();

charc;

do

{

printf("Pleaseenterthe's'toquerytheshortestpath\n");

printf("Pleaseenterthe'i'toqueryinformation\n");

printf("Pleaseinput'e'toexittheprogram\n\n\n");

loop:

scanf("%c",&c);

if(c>='A'&&c<='Z')

{

c+=32;

}

if(c=='\n')

{

gotoloop;

}

if(c!

='\n')

{

if(c=='s')

{

shortestpath();

continue;

}

elseif(c=='i')

{

Information();

continue;

}

elseif(c=='e')

{

printf("\n\n\n\t\t\t\tThankyouforyouuse\n\n\n");

return0;

}

else

{

printf("inputerror!

!

!

\n");

continue;

}

}

}while

(1);

return0;

}

2)赋值init函数

voidinit()

{

inti,j;

vertex[1].number=1;

strcpy(vertex[1].name,"AreaCdormitorybuilding");

strcpy(vertex[1].introduce,"AreaCstudentrestarea");

vertex[2].number=2;

strcpy(vertex[2].name,"AreaAdormitorybuilding");

strcpy(vertex[2].introduce,"AreaAstudentrestarea");

vertex[3].number=3;

strcpy(vertex[3].name,"AreaBdormitorybuilding");

strcpy(vertex[3].introduce,"AreaBstudentrestarea");

vertex[4].number=4;

strcpy(vertex[4].name,"AreaCrestaurant");

strcpy(vertex[4].introduce,"AreaCstudentdiningarea");

vertex[5].number=5;

strcpy(vertex[5].name,"AreaArestaurant");

strcpy(vertex[5].introduce,"AreaAstudentdiningarea");

vertex[6].number=6;

strcpy(vertex[6].name,"AreaBrestaurant");

strcpy(vertex[6].introduce,"AreaBstudentdiningarea");

vertex[7].number=7;

strcpy(vertex[7].name,"library");

strcpy(vertex[7].introduce,"Studentborrowingbooksarea");

*vertex[7].number=8;

strcpy(vertex[7].name,"AreaArestaurant");

strcpy(vertex[7].introduce,"AreaAstudentdiningarea");*

vertex[8].number=8;

strcpy(vertex[8].name,"No.1teachingbuilding");

strcpy(vertex[8].introduce,"Studentsinclassarea");

vertex[9].number=9;

strcpy(vertex[9].name,"No.13teachingbuilding");

strcpy(vertex[9].introduce,"Informationinstitute,collegebuilding");

for(i=1;i

{

for(j=1;j

{

dist[i][j]=INFINITY;

}

}

for(i=1;i

{

dist[i][i]=0;

}

dist[1][2]=dist[2][1]=20;

dist[2][3]=dist[3][2]=40;

dist[1][4]=dist[4][1]=50;

dist[2][5]=dist[5][2]=30;

dist[3][6]=dist[6][3]=50;

dist[4][5]=dist[5][4]=70;

dist[5][6]=dist[6][5]=90;

dist[4][7]=dist[7][4]=100;

dist[5][8]=dist[8][5]=120;

dist[6][9]=dist[9][6]=80;

dist[7][8]=dist[8][7]=60;

dist[8][9]=dist[9][8]=120;

}

3)输出山东科技大学平面图的map函数

voidmap()

{

printf("thescienceandtechnologyofShandonguniversitymap\n");

printf("\n\n");

printf("

(1)AreaCdormitorybuilding---

(2)AreaAdormitorybuilding---(3)AreaBdormitorybuilding\n");

printf("|||\n");

printf("|||\n");

printf("|||\n");

printf("(4)AreaCrestaurant------(5)AreaAprintf("|||\n");

printf("|||\n");

printf("|||\n");

printf("\n\n\n");

}

4)输出地点信息的information函数

voidInformation()

{

intnumber;

while

(1)

{

printf("Pleaseenterthenumberofquerysite:

");

scanf("%d",&number);

if(number0)

{

return;

}

else

{

printf("inputerror!

!

\n");

}

}

}

5)最短路径floyd函数

voidfloyd()*弗洛伊德算法*

{

inti,j,u;

for(i=1;i

{

for(j=1;j

{

shortest[i][j]=dist[i][j];

path[i][j]=0;

}

}

for(u=1;u

{

for(i=1;i

{

for(j=1;j

{

if(shortest[i][j]>(shortest[i][u]+shortest[u][j]))

{

shortest[i][j]=shortest[i][u]+shortest[u][j];

path[i][j]=path[j][i]=u;

}

}

}

}

}

6)输出路径Path算法

voidPath(inti,intj)*最短路径的输出*

{

intu=0;

inta,b;

a=i;

b=j;

if(shortest[i][j]!

=INFINITY)

{

printf("\nTheshortestpathfrom%sto%sis:

\n\n",vertex[i].name,vertex[j].name);

printf("%s",vertex[i].name);

while(path[i][j]!

=0)

{

u=path[i][j];

while(path[i][u]!

=0)

{

u=path[i][u];

}

printf("--%s",vertex[u].name);

i=u;

}

printf("--%s;\n",vertex[j].name);

printf("\nTheshortestdistanceis:

%dmeters.\n",shortest[a][b]);

}

}

7)调用floyd和Path的最短路径shortestpath算法

voidshortestpath()

{

inti,j;

while

(1)

{

printf("Pleaseenterthenumbertwotoquery:

");

scanf("%d%d",&i,&j);

if(i>0&&i0&&j

{

floyd();

printf("==========\n");

Path(i,j);

return;

}

}

}

3.函数的调用关系

 

4.4测试与分析

4.4.1测试

1)打开程序后,出现我校平面图和菜单选项,如图所示

2)

2)选“i”,查询对应地点的信息,如输入“3”,而后会继续输出菜单,如图所示

3)选“s”,查询两点之间的信息,如输入“17”,而后会继续输出菜单,如图所示

4)选“e”,推出程序,如图所示

4.4.2分析

1.本次作业的核心是利用弗洛伊德算法计算给定图中两点最短距离;给出图中所要求点的信息。

在调试过程中,除了简单语法错误外,就是对弗洛伊德算法的理解和实现,以及菜单的设置,这是我以前没有实现过的。

出于简单化,并没有对有向图中各个点进行输入,而是在程序中直接赋值。

2.在对各个功能操作的实现上,由于有弗洛伊德算法时间复杂度大多数是O(n3),空间上增加了二维数组,空间复杂度为O(n+s)。

4.5附录

Map.");

printf("\n\n");

printf("

(1)AreaCdormitorybuilding---

(2)AreaAdormitorybuilding---(3)AreaBdormitorybuilding\n");

printf("|||\n");

printf("|||\n");

printf("|||\n");

restaurant\n");

printf("|||\n");

printf("|||\n");

printf("|||\n");

building\n");

printf("\n\n\n");

}

voidinit()

{

inti,j;

vertex[1].number=1;

strcpy(vertex[1].name,"AreaCdormitorybuilding");

strcpy(vertex[1].introduce,"AreaCstudentrestarea");

vertex[2].number=2;

strcpy(vertex[2].name,"AreaAdormitorybuilding");

strcpy(vertex[2].introduce,"AreaAstudentrestarea");

vertex[3].number=3;

strcpy(vertex[3].name,"AreaBdormitorybuilding");

strcpy(vertex[3].introduce,"AreaBstudentrestarea");

vertex[4].number=4;

strcpy(vertex[4].name,"AreaCrestaurant");

strcpy(vertex[4].introduce,"AreaCstudentdiningarea");

vertex[5].number=5;

strcpy(vertex[5].name,"AreaArestaurant");

strcpy(vertex[5].introduce,"AreaAstudentdiningarea");

vertex[6].number=6;

strcpy(vertex[6].name,"AreaBrestaurant");

strcpy(vertex[6].introduce,"AreaBstudentdiningarea");

vertex[7].number=7;

strcpy(vertex[7].name,"library");

strcpy(vertex[7].introduce,"Studentborrowingbooksarea");

*vertex[7].number=8;

strcpy(vertex[7].name,"AreaArestaurant");

strcpy(vertex[7].introduce,"AreaAstudentdiningarea");*

vertex[8].number=8;

strcpy(vertex[8].name,"No.1teachingbuilding");

strcpy(vertex[8].introduce,"Studentsinclassarea");

vertex[9].number=9;

strcpy(vertex[9].name,"No.13teachingbuilding");

strcpy(vertex[9].introduce,"Informationinstitute,collegebuilding");

for(i=1;i

{

for(j=1;j

{

dist[i][j]=INFINITY;

}

}

for(i=1;i

{

dist[i][i]=0;

}

dist[1][2]=dist[2][1]=20;

dist[2][3]=dist[3][2]=40;

dist[1][4]=dist[4][1]=50;

dist[2][5]=dist[5][2]=30;

dist[3][6]=dist[6][3]=50;

dist[4][5]=dist[5][4]=70;

dist[5][6]=dist[6][5]=90;

dist[4][7]=dist[7][4]=100;

dist[5][8]=dist[8][5]=120;

dist[6][9]=dist[9][6]=80;

dist[7][8]=dist[8][7]=60;

dist[8][9]=dist[9][8]=120;

}

voidInformation()

{

intnumber;

while

(1)

{

printf("Pleaseenterthenumberofquerysite:

");

scanf("%d",&number);

if(number0)

{

return;

}

else

{

printf("inputerror!

!

\n");

}

}

}

voidfloyd()*弗洛伊德算法*

{

inti,j,u;

for(i=1;i

{

for(j=1;j

{

shortest[i][j]=dist[i][j];

path[i][j]=0;

}

}

for(u=1;u

{

for(i=1;i

{

for(j=1;j

{

if(shortest[i][j]>(shortest[i][u]+shortest[u][j])

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 唐诗宋词

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1