北京工业大学2014数据结构课设北京地铁查询C++版

上传人:鲁** 文档编号:504643922 上传时间:2024-01-26 格式:DOCX 页数:14 大小:26.50KB
返回 下载 相关 举报
北京工业大学2014数据结构课设北京地铁查询C++版_第1页
第1页 / 共14页
北京工业大学2014数据结构课设北京地铁查询C++版_第2页
第2页 / 共14页
北京工业大学2014数据结构课设北京地铁查询C++版_第3页
第3页 / 共14页
北京工业大学2014数据结构课设北京地铁查询C++版_第4页
第4页 / 共14页
北京工业大学2014数据结构课设北京地铁查询C++版_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《北京工业大学2014数据结构课设北京地铁查询C++版》由会员分享,可在线阅读,更多相关《北京工业大学2014数据结构课设北京地铁查询C++版(14页珍藏版)》请在金锄头文库上搜索。

1、2014 年北京工业大学计算机学院数据结构与算法课设嗨,你好。当年为了这个该死的课设我也是和你一样急,在 CSDN 上各种找但是没有。最后还好弄出来了。C+版本题目什么的在下面,附件什么的我都在这个DOC 中给你。祝你能过。2014.11.01数据结构与算法课程设计报告北京地铁查询系统学号:12 07 01姓名:哈哈指导教师:呵呵2014年10月1.1设计的描述当今的北京,地铁已经成为绝大多数人出行的首选。截至2014 年 1月,北京地铁共有 17 条运营线路。组成覆盖北京市11个市辖区,拥有231 座运营车站、总长467 千米运营线 路的轨道交通系统,工作日均客流约1000 万人次,峰值日客

2、运量1155.92万人次。随着地 铁线路的增加,地铁规模越来越大,人们愈发的感觉到地铁的便利。特别地从出发地到目的 地的乘车方案的选择也越来越多。因此,需要提供一个软件能够为人们提供出发到目的地之 间“最快”或“最方便”的地铁出行方案。其中,“最快”指用时最少,“最方便”则指在 换乘车少的基础上用时最少。1.2设计的需求请设计一个地铁出行帮助系统,为北京市居民提供地铁出行方案(仅限地铁出行)。提 供出发地和目的地地铁站的输入窗口,提供出行建议,并图形显示出线路。出行建议信息:出发站,第2站,站名,站名,几号线几号线第i站,站名,几号线换乘站,站名,换乘几号线*第m站,站名,几号线目的站,站名,

3、几号线总用时,X分钟,换乘次数:N1.2.1输入数据要求地铁线路基础信息数据通过一个名为“BaseInfo, txt”的文本文件读入。 该数据文件格式如下:第0行:当前系统中地铁线路的条数n (n0) 第1行:第1条地铁线路名称(如:1号线),第1站(如:四惠东站),图上 坐标(如: X1,Y1 ) 2,运行时间(如: 3 ) ,第2站(如:四惠站) ,图上坐标(如:X2,Y2)/运行时间(如:4),,第23站(如:苹果园站),图上 坐标(如:X ,Y )nn 第i行:第i条地铁线路名称,第1站,运行时间,第2站,运行时间,第 n站 第n行:第n条地铁线路名称,第1站,运行时间,第2站,运行时

4、间,第 n站 第n +1行:换乘站数目m (m 0) 换乘编号1#:换乘站名称1(如:四惠东站),(下车线路(如:1号线),1 *表示可能有若干次换乘,也可能没有换乘。每次换乘的信息为(换乘站,站名,换乘几号线)2 坐标根据采用的地铁图中的相对位置来给出(由同学自己根据所选地铁图大小进行设置)换乘线路(如:八通线),换乘时间3(如:5)+4 换乘编号i#:换乘站名称i,下车线路,换乘线路,换乘时间 换乘编号m#:换乘站名称m,下车线路,换乘线路,换乘时间用户查询信息通过图形界面的对话框提供: 包括起始站,目的站的输入框。1.2.2输出画面的要求用图形方式显示北京市地铁图,并根据客户的输入提供建

5、议(文字展示)并以加粗的两 端带红点的绿色线路形式绘制在地铁图上。1.2.3题目约定 题目中的时间单位为分钟; 地铁一般一站运行时间3分钟,个别长的站为5分钟。 最短距离以所用时间表示1.2.4题目实现要求 应用最短路径算法,求任意两站间的“最快”,“最方便”的出行方案。特别需要 注意换乘站的处理。5.0代码清单#include#include#include#include using namespace std;typedef struct ArcNodeint adjvex;string line;int time;struct ArcNode *nextarc;ArcNode;3 换乘

6、时间以分钟为单位4 相同的换乘站可以换乘不同的地铁线路,比如西直门换乘站 typedef struct VNodestring station;int cost;string path;string from;ArcNode *firstarc;VNode;typedef struct Transferstring from;string to;int time; struct Transfer *nextarc;Transfer;typedef struct TransferStationstring station; Transfer *firstarc;TransferStation;v

7、oid split(const string&, const string&, vector&); int findIndex(vector, string);int findIndex(vector, int);int findTransferTime(string, string, string);void initialize();string findOptimalPath(string, string, int&);vector AdjList; vector TransferInfo;void main() initialize();int cost;string start,de

8、s;cou t欢迎使用n;cou t输入起点站:; cinstart;cou t输入终点站:;cindes;string s = findOptimalPath(start, des, cost);cou t线路为:; couts.c_str()x;void initialize()ifstream in(BaseInfo.txt); /读入文件 string s;int linesNum; string line; vectorstring v;int time;VNode *vn;ArcNode *an;Transfer *t; TransferStation *ts;int i, ind

9、ex, startIndex;int index1, index2;getline(in, s);linesNum = atoi(s.c_str();getline(in, s); split(s, , v);line = v0;vn = new VNode(); vn-station = v1;vn-cost = 10000; vn-path = ; vn-from = ; vn-firstarc = NULL; AdjList.push_back(*vn);for(i=2; iv.size()-1; i=i+2)time = atoi(vi.c_str(); index = AdjList

10、.size();an = new ArcNode(); an-line = line;an-adjvex = index; an-time = time;/前插法an-nextarc = vn-firstarc; AdjListi/2-1.firstarc = an;an = new ArcNode(); an-line = line; an-adjvex = index - 1;an-time = time; an-nextarc = NULL;vn = new VNode(); vn-station = vi+1;vn-cost = 10000;vn-path = ; vn-from =

11、;vn-firstarc = an; AdjList.push_back(*vn);if(i = v.size()-1)time = atoi(vi.c_str();an = new ArcNode(); an-line = line; an-adjvex = 0; an-time = time; an-nextarc = vn-firstarc; AdjList.back().firstarc = an;an = new ArcNode(); an-line = line; an-adjvex = index;an-time = time;an-nextarc = AdjList0.firs

12、tarc; AdjList0.firstarc = an;while(linesNum- 1)getline(in, s); v.clear(); split(s, , v);line = v0;index1 = findIndex(AdjList, v1); if(index1 = -1)vn = new VNode(); vn-station = v1; vn-cost = 10000; vn-from = ; vn-path = ; vn-firstarc = NULL; AdjList.push_back(*vn); index1 = AdjList.size() - 1; start

13、Index = index1;for(i=2; istation = vi+1; vn-cost = 10000; vn-from = ; vn-path = ;vn-firstarc = NULL; AdjList.push_back(*vn);index2 = AdjList.size() - 1;an = new ArcNode(); an-line = line; an-adjvex = index1; an-time = time;/前插法an-nextarc =AdjListindex2.firstarc; AdjListindex2.firstarc = an;an = new ArcNode(); an-line = line; an-adjvex = index2; an-time = time;an-nextarc = AdjListindex1.firstarc;AdjListindex1.firstarc = an;index1 = index2;if(i = v.size()-1)time = atoi(vi.c_str();an = new ArcNode();an-line = line;an-adjvex = startIndex;an-

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号