C++校园导游系统课程设计.docx

上传人:b****2 文档编号:16864031 上传时间:2023-07-19 格式:DOCX 页数:18 大小:52.41KB
下载 相关 举报
C++校园导游系统课程设计.docx_第1页
第1页 / 共18页
C++校园导游系统课程设计.docx_第2页
第2页 / 共18页
C++校园导游系统课程设计.docx_第3页
第3页 / 共18页
C++校园导游系统课程设计.docx_第4页
第4页 / 共18页
C++校园导游系统课程设计.docx_第5页
第5页 / 共18页
C++校园导游系统课程设计.docx_第6页
第6页 / 共18页
C++校园导游系统课程设计.docx_第7页
第7页 / 共18页
C++校园导游系统课程设计.docx_第8页
第8页 / 共18页
C++校园导游系统课程设计.docx_第9页
第9页 / 共18页
C++校园导游系统课程设计.docx_第10页
第10页 / 共18页
C++校园导游系统课程设计.docx_第11页
第11页 / 共18页
C++校园导游系统课程设计.docx_第12页
第12页 / 共18页
C++校园导游系统课程设计.docx_第13页
第13页 / 共18页
C++校园导游系统课程设计.docx_第14页
第14页 / 共18页
C++校园导游系统课程设计.docx_第15页
第15页 / 共18页
C++校园导游系统课程设计.docx_第16页
第16页 / 共18页
C++校园导游系统课程设计.docx_第17页
第17页 / 共18页
C++校园导游系统课程设计.docx_第18页
第18页 / 共18页
亲,该文档总共18页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

C++校园导游系统课程设计.docx

《C++校园导游系统课程设计.docx》由会员分享,可在线阅读,更多相关《C++校园导游系统课程设计.docx(18页珍藏版)》请在冰点文库上搜索。

C++校园导游系统课程设计.docx

C++校园导游系统课程设计

DONGFANGCOLLEGE,FUJIANAGRICULTUREANDFORESTRYUNIVERSITY

C++程序设计课程设计报告

课程设计:

校园导游系统

系别:

计算机系年级:

10级

专业:

计算机科学与技术

班级:

1班学号:

姓  名:

成绩:

任课教师:

2012年8月20日

1.需求分析…………………………………………………3

2.概要设计.............................………………………………3

3.详细设计………………………………………………….3

4.使用说明………………………………………………….3

5.测试结果……………………………………………….…4

6.附录………………………………………………………5

7.参考文献…………………………………………………14

 

1.

需求分析

设计一个校园导游程序,为来访的客人提供各种信息查询服务。

2.概要设计

(1)设计你所在学校的校园平面图,所含景点不少于10个。

以图中顶点表示校内各景点,存放景点名称、代号、简介等信息;以边表示路径,存放路径长度等相关信息。

(2)为来访客人提供图中任意景点相关信息的查询。

(3)为来访客人提供图中任意景点的问路查询,即查询任意两个景点之间的一条最短的简单路径。

3.详细设计

1.以输出流显示校园的界面

2.以图的形式存储校园景点

3.以循环算法运行操作界面

4.以函数调用实现导游功能

4.使用说明

1.运行时显示校园景观图,同时显示选择菜单

2.选择菜单:

1.地点介绍2.最短路径3.结束“请选择功能”

3.地点介绍:

出现景点选择:

A.操场B.偏门C.图书馆D.大门E.食堂F.诚智楼G.博学楼H.创新楼I.海天楼J.明德楼请选择地点(选择加回车即能查询景点信息)

4.最短路径:

出现“输入起点位置”,输入后即出现“输入终点位置”(输入加回车即显示两景点的最短路径)

5.测试结果

1.运行界面

2.地点介绍

3.最短路径

6.附录

1.校园景观图实现函数:

voidviewshow()

{

cout<<"东方学院实景图"<

cout<<""<

cout<<"A操场-----B偏门"<

cout<<"/\\"<

cout<<"/\\"<

cout<<"C图书馆------D大门E食堂----------\\"<

cout<<"/\\\\"<

cout<<"/\\F诚智楼---G博学楼-H创新楼"<

cout<<"/\\/"<

cout<<"I海天楼--------J明德楼"<

cout<<""<

}

2.建立图函数:

#include"SeqList.h"

#include"SeqQueue.h"

constintMaxVertices=10;

constintMaxWeight=10000;

classAdjMWGraph

{

private:

SeqListVertices;//顶点信息的线性表

intEdge[MaxVertices][MaxVertices];

intnumOfEdges;

public:

AdjMWGraph(constintsz=MaxVertices);

intGraphEmpty()const

{returnVertices.ListEmpty();}

intNumOfVertices(void)

{returnVertices.ListSize();}

intNumOfEdges(void)

{returnnumOfEdges;}

VerTGetValue(constinti);

intGetWeight(constintv1,constintv2);

voidInsertVertex(constVerT&vertex);

voidInsertEdge(constintv1,constintv2,intweight);

voidDeleteVertex(constinti);

voidDeleteEdge(constintv1,constintv2);

intGetFirstNeighbor(constintv);

intGetNextNeighbor(constintv1,constintv2);

voidDepthFirstSearch(constintv,intvisited[],voidvisit(VerTitem));

voidBroadFirstSearch(constintv,intvisited[],voidvisit(VerTitem));

voidDepthFirstSearch(voidvisit(VerTitem));

voidBroadFirstSearch(voidvisit(VerTitem));

};

AdjMWGraph:

:

AdjMWGraph(constintsz)

{

for(inti=0;i

for(intj=0;j

{

if(i==j)Edge[i][j]=0;

elseEdge[i][j]=MaxWeight;

}

numOfEdges=0;

}

VerTAdjMWGraph:

:

GetValue(constinti)

{

if(i<0||i>Vertices.ListSize())

{

cerr<<"参数i越界出错!

"<

exit

(1);

}

returnVertices.GetData(i);

}

intAdjMWGraph:

:

GetWeight(constintv1,constintv2)

{

if(v1<0||v1>Vertices.ListSize()||v2<0||v2>Vertices.ListSize())

{

cerr<<"参数v1或v2越界出错!

"<

exit

(1);

}

returnEdge[v1][v2];

}

voidAdjMWGraph:

:

InsertVertex(constVerT&vertex)

{

Vertices.Insert(vertex,Vertices.ListSize());

}

voidAdjMWGraph:

:

InsertEdge(constintv1,constintv2,intweight)

{

if(v1<0||v1>Vertices.ListSize()||v2<0||v2>Vertices.ListSize())

{

cerr<<"参数v1或v2越界出错!

"<

exit

(1);

}

Edge[v1][v2]=weight;

numOfEdges++;

}

voidAdjMWGraph:

:

DeleteVertex(constintv)

{

for(inti=0;i

for(intj=0;j

if((i==v||j==v)&&Edge[i][j]>0&&Edge[i][j]

{

Edge[i][j]=MaxWeight;

numOfEdges--;

}

Vertices.Delete(v);

}

voidAdjMWGraph:

:

DeleteEdge(constintv1,constintv2)

{

if(v1<0||v1>Vertices.ListSize()||v2<0||v2>Vertices.ListSize()||v1==v2)

{

cerr<<"参数v1或v2出错!

"<

exit

(1);

}

Edge[v1][v2]=MaxWeight;

numOfEdges--;

}

intAdjMWGraph:

:

GetFirstNeighbor(constintv)

{

if(v<0||v>Vertices.ListSize())

{

cerr<<"参数v1越界出错!

"<

exit

(1);

}

for(intcol=0;col<=Vertices.ListSize();col++)

if(Edge[v][col]>0&&Edge[v][col]

return-1;

}

intAdjMWGraph:

:

GetNextNeighbor(constintv1,constintv2)

{

if(v1<0||v1>Vertices.ListSize()||v2<0||v2>Vertices.ListSize())

{

cerr<<"参数v1或v2越界出错!

"<

exit

(1);

}

for(intcol=v2+1;col<=Vertices.ListSize();col++)

if(Edge[v1][col]>0&&Edge[v1][col]

return-1;

}

voidAdjMWGraph:

:

DepthFirstSearch(constintv,intvisited[],voidvisit(VerTitem))

{

visit(GetValue(v));

visited[v]=1;

intw=GetFirstNeighbor(v);

while(w!

=-1)

{

if(!

visited[w])DepthFirstSearch(w,visited,visit);

w=GetNextNeighbor(v,w);

}

}

voidAdjMWGraph:

:

BroadFirstSearch(constintv,intvisited[],voidvisit(VerTitem))

{

VerTu,w;

SeqQueuequeue;//定义队列queue

visit(GetValue(v));

visited[v]=1;

queue.QInsert(v);

while(!

queue.QueueEmpty())

{

u=queue.QDelete();

w=GetFirstNeighbor(u);

while(w!

=-1)

{

if(!

visited[w])

{

visit(GetValue(w));

visited[w]=1;

queue.QInsert(w);

}

w=GetNextNeighbor(u,w);

}

}

}

voidAdjMWGraph:

:

DepthFirstSearch(voidvisit(VerTitem))

{

int*visited=newint[NumOfVertices()];

for(inti=0;i

for(i=0;i

if(!

visited[i])DepthFirstSearch(i,visited,visit);

delete[]visited;

}

//非连通图的广度优先搜索遍历算法如下

voidAdjMWGraph:

:

BroadFirstSearch(voidvisit(VerTitem))

{

int*visited=newint[NumOfVertices()];

for(inti=0;i

for(i=0;i

if(!

visited[i])BroadFirstSearch(i,visited,visit);

delete[]visited;

}

structRowColWeight

{

introw;

intcol;

intweight;

};

voidCreatGraph(AdjMWGraph&G,DatatypeV[],intn,RowColWeightE[],inte)//建图

{

for(inti=0;i

for(intk=0;k

}

voidPrintchar(charitem)

{

cout<

}

voidDijkstra(AdjMWGraph&G,intv0,intdistance[],intpath[])

{

intn=G.NumOfVertices();

int*s=newint[n];

intminDis,i,j,u;

for(i=0;i

{

distance[i]=G.GetWeight(v0,i);

s[i]=0;

if(i!

=v0&&distance[i]

elsepath[i]=-1;

}

s[v0]=1;

for(i=1;i

{

minDis=MaxWeight;

for(j=0;j<=n;j++)

if(s[j]==0&&distance[j]

{

u=j;

minDis=distance[j];

}

if(minDis==MaxWeight)return;

s[u]=1;

for(j=0;j

if(s[j]==0&&G.GetWeight(u,j)

{

distance[j]=distance[u]+G.GetWeight(u,j);

path[j]=u;

}

}

}

3.主函数:

typedefcharVerT;

typedefcharDatatype;

#include"AdjMWGraph.h"

#include"View.h"

intmain()

{

ints,sss=1,j=1;

charch,qd,zd;

AdjMWGraphg;

chara[]={'A','B','C','D','E','F','G','H','I','J'};

RowColWeightrcw[]={{0,1,20},{0,3,30},{0,4,30},{1,0,20},{2,3,20},{3,0,30},{3,2,20},{3,8,30},{3,9,20},{4,0,30},{4,6,20},{5,6,15},{5,9,15},{6,4,20},{6,5,15},{6,7,10},{7,6,10},{8,3,30},{8,9,15},{9,5,15},{9,8,15}};

intn=10,e=24;

CreatGraph(g,a,n,rcw,e);

intm=g.NumOfVertices();

int*distance=newint[m];

int*path=newint[m];

intv0=0,v1;

Dijkstra(g,v0,distance,path);

end:

if(j==0){system("cls");}

do{

viewshow();

cout<<"1.地点介绍2.最短路径3.结束"<

";

cin>>s;

system("cls");

if(s==1)

{

do{

viewshow();

cout<<"A.操场B.偏门C.图书馆D.大门E.食堂"<

<<"F.诚智楼G.博学楼H.创新楼I.海天楼J.明德楼"<

";

cin>>ch;

switch(ch)

{

case'A':

zhengdamenshow();

cin.get();

cin.get();

system("cls");break;

case'B':

mdshow();

cin.get();

cin.get();

system("cls");break;

case'C':

czshow();

cin.get();

cin.get();

system("cls");break;

case'D':

bxshow();

cin.get();

cin.get();

system("cls");break;

case'E':

cxshow();

cin.get();

cin.get();

system("cls");break;

case'F':

bahaoshow();

cin.get();

cin.get();

system("cls");break;

case'G':

sitangshow();

cin.get();

cin.get();

system("cls");break;

case'H':

shihaoshow();

cin.get();

cin.get();

system("cls");break;

case'I':

caochangshow();

cin.get();

cin.get();

system("cls");break;

case'J':

tushuguanshow();

cin.get();

cin.get();

system("cls");break;

case'K':

j=0;

gotoend;

default:

cout<<"选择有误,请重新选择!

"<

cin.get();

cin.get();

system("cls");

}

}while

(1);

}

if(s==2)

{

do{

viewshow();

QIDIAN:

cout<<"请输入起点位置:

";

cin>>qd;

if(qd=='A')v0=0;

elseif(qd=='B')v0=1;

elseif(qd=='C')v0=2;

elseif(qd=='D')v0=3;

elseif(qd=='E')v0=4;

elseif(qd=='F')v0=5;

elseif(qd=='G')v0=6;

elseif(qd=='H')v0=7;

elseif(qd=='I')v0=8;

elseif(qd=='J')v0=9;

else{cout<<"起点输入有误,请重新输入!

"<

cout<<"请输入终点位置:

";

cin>>zd;

if(zd=='A')v1=0;

elseif(zd=='B')v1=1;

elseif(zd=='C')v1=2;

elseif(zd=='D')v1=3;

elseif(qd=='E')v1=4;

elseif(zd=='F')v1=5;

elseif(zd=='G')v1=6;

elseif(zd=='H')v1=7;

elseif(zd=='I')v1=8;

elseif(zd=='J')v1=9;

else{cout<<"终点输入有误,请重新输入!

"<

cout<<"起点"<

"<

cout<<"是否继续查询:

1.是2.否;请选择:

";

cin>>sss;

system("cls");

}while(sss==1);

}

if(s==3){cout<<"谢谢使用!

"<

}while

(1);

}

7.参考文献

数据结构——使用C++语言(第二版)朱战立编著

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

当前位置:首页 > 临时分类 > 批量上传

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2