对飞机航班信息进行排序和查找

上传人:jin****ng 文档编号:176025546 上传时间:2022-12-20 格式:DOCX 页数:10 大小:47.48KB
收藏 版权申诉 举报 下载
对飞机航班信息进行排序和查找_第1页
第1页 / 共10页
对飞机航班信息进行排序和查找_第2页
第2页 / 共10页
对飞机航班信息进行排序和查找_第3页
第3页 / 共10页
资源描述:

《对飞机航班信息进行排序和查找》由会员分享,可在线阅读,更多相关《对飞机航班信息进行排序和查找(10页珍藏版)》请在装配图网上搜索。

1、数据结构实验报告姓 名: 专业 任课老师:名: 业:信息技术试验编号:试验五学 号: 班级 辅导教师: 小组成员:一、实验项目:航班信息查询二、实验目的:对飞机航班信息进行排序和查找。三、实验内容: 对飞机航班信息进行排序和查找。可按航班的航班号、起点站、到达站、起 飞时间以及到达时间等信息进行查询。四、需求分析1、先对飞机航班进行排序; 2、根据飞机的各个信息进行查找;五、概要设计1、 根据要实现的功能,应该以链表来表示集合,所以需要构造的数据类型为链表和集合。集合。2、结构体hangbanstruct hangbanchar k6; string qd; string zd; string

2、 bq; int btime; int etime; string jx; int price;/航班号 /起点站 /终点站 /班期 /起飞时间 /到达时间 /机型 /票价;/结构体 hangban3、部分函数功能简介 void initb() void printb() void chazhao() void findk() void findqd() void findzd() void findbq() void findbtime()/创建表/输出/查找信息 /按航班号查找 /按起点站查找 /按终点站查找 /按班期查找 /按起飞时间查找void findetime( ) void fi

3、ndjx() void findprice() 六、详细设计 #include/按到达时间查找/按机型查找/按票价查找using namespace std; struct hangbanchar k6;string qd;string zd;string bq;int btime;int etime;string jx;int price;/ 结构体 hangban const int n=3;hangban hn; void initb()/航班号/起点站/终点站 /班期 /起飞时间 /到达时间 /机型 /票价/创建航班信息表int l;hangban h1;for(int i=0;in;

4、i+)/输入航班信息cout 输入第 i+1 个航班的信息 endl;cou t输入航班号endl;for(int j=0;jhi.kj; cou t输入起点站hi.qd;cou t输入终点站hi.zd;cou t输入班期hi.bq;cou t输入起飞时间hi.btime;cou t输入到达时间hi.etime;cou t输入机型hi.jx;cou t输入票价hi.price;for(int i=0;in-1;i+)/按航班号排序for(int j=0;jn-i-1;j+)l=2;while(lhj+1.kl) h1=hj;hj=hj+1;hj+1=h1;break; else if(hj.k

5、l=hj+1.kl) l+; else if(hj.klhj+1.kl) break; void printb()/显示航班信息表for(int i=0;in;i+)cout 第 i+1 个航班的信息 endl; cout 航班号 起点站 终点站 班期 起飞时间 到达时间 机型 票价 endl;for(int j=0;j6;j+) couthi.kj;cout ;couthi.qd;couthi.zd;couthi.bq;couthi.btime;couthi.etime;couthi.jx;couthi.price;coutendl;void findk()/通过航班号查询int count

6、=0;cout 通过航班号查询 endl;char a6;cout 输入要查询的航班号 :;for(int i=2;iai;int j;for(int i=0;in;i+)j=2;while(j6)if(hi.kj=aj) j+; else break;if(j=6) cout 第 i+1 个航班是要查找的航班 endl;count+;cout 第 i+1 个航班的信息 endl;cout 航班号 起点站 终点站 班期起飞时间 到达时间 机型 票价 endl;for(int j=0;j6;j+) couthi.kj;cout ;couthi.qd;couthi.zd;couthi.bq;cou

7、thi.btime;couthi.etime;couthi.jx;couthi.price;coutendl;if(count=0) cout 没有符合要求的航班 endlendl;void findqd()/通过起点站查找int count=0;coutk;for(int i=0;in;i+)if(k=hi.qd)cout 第 i+1 个航班是要查找的航班endl;count+;cout 第 i+1 个航班的信息 endl;cout 航班号 起点站 终点站 班期 起飞 时间 到达时间 机型 票价 endl;for(int j=0;j6;j+) couthi.kj;cout ;couthi.q

8、d;couthi.zd;couthi.bq;couthi.btime;couthi.etime;couthi.jx;couthi.price;coutendl;if(count=0) cout 没有符合要求的航班 endlendl;void findzd()/通过终点站查找int count=0;coutk;for(int i=0;in;i+)if(k=hi.zd)cout 第 i+1 个航班是要查找的航班 endl;count+;cout 第 i+1 个航班的信息 endl;cout 航班号 起点站 终点站 班期 起飞时间 到达时间 机型 票价 endl; for(int j=0;j6;j+

9、) couthi.kj;cout ;couthi.qd;couthi.zd;couthi.bq;couthi.btime;couthi.etime;couthi.jx;couthi.price;coutendl;if(count=0) cout 没有符合要求的航班 endlendl;void findbq()/通过班期查找int count=0;coutk;for(int i=0;in;i+)if(k=hi.bq) cout 第 i+1 个航班是要查找的航班 endl;count+;cout 第 i+1 个航班的信息 endl;cout 航班号 起点站 终点站 班期 起飞时间 到达时间 机型

10、票价 endl; for(int j=0;j6;j+) couthi.kj;cout ;couthi.qd;couthi.zd;couthi.bq;couthi.btime ;couthi.etime;couthi.jx ;couthi.price;coutendl;if(count=0) cout 没有符合要求的航班 endlendl;void findbtime()/通过起飞时间查找int count=0;coutk;for(int i=0;in;i+)if(k=hi.btime) cout 第 i+1 个航班是要查找的航班endl;count+;cou t 第i+l个航班的信息 endl

11、;cout 航班号 起点站 终点站 班期 起飞时间 到达时间 机型 票价 endl; for(int j=0;j6;j+) couthi.kj;cout;couthi.qd;couthi.zd;couthi.bq;couthi.btime;couthi.etime;couthi.jx;couthi.price;coutendl;if(coun t二=0) cou t没有符合要求的航班 endlendl;void findetime()/通过到达时间查找int count=0;cou tk;for(int i=0;in;i+)if(k=hi.etime) cout 第 i+1 个航班是要查找的航

12、 班endl;count+;cou t 第i+l个航班的信息 endl;cout 航班号 起点站 终点站 班期 起飞时间 到达时间 机型 票价 endl;for(int j=0;j6;j+) couthi.kj;cout;couthi.qd;couthi.zd;couthi.bq;couthi.btime;couthi.etime;couthi.jx;couthi.price;coutendl;if(coun t二=0) cou t没有符合要求的航班 endlendl;void findjx()/通过机型查找int count=0;cou t k;for(int i=0;in;i+)if(k=

13、hi.jx) cou t 第i+l个航班是要查找的航班 endl;count+;cou t 第i+l个航班的信息 endl;cout 航班号 起点站 终点站 班期 起飞时间 到达时间 机型 票价 endl; for(int j=0;j6;j+) couthi.kj;cout;couthi.qd;couthi.zd;couthi.bq;couthi.btime;couthi.etime;couthi.jx;couthi.price;coutendl;if(count=0) cout 没有符合要求的航班 endlendl;void findprice()/通过票价查找int count=0;cou

14、tk;for(int i=0;in;i+)if(k=hi.price) cout 第 i+1 个航班是要查找的航班endl;count+;cou t 第i+l个航班的信息 endl;cout 航班号 起点站 终点站 班期 起飞时间 到达时间 机型 票价 endl;for(int j=0;j6;j+) couthi.kjcout;couthi.qd.7couthi.zd.7couthi.bq.7couthi.btime.7couthi.etime.7couthi.jx.7couthi.price.7coutendl;if(coun t二=0) cou t没有符合要求的航班 endlendl;vo

15、id chazhao()/查找信息cout 菜单 2 endl;cout 1.按航班号查找endl;cout2.按起点站查找endl;cout3.按终点站查找endl;cout4.按班期查找endl;cout5.按起飞时间查找endl;cout6.按到达时间查找endl;cout7.按机型查找endl;cout8.按票价查找endl;cout9. 回到菜单 1endl;cout输入选择:k2)if(k2=1) findk(); if(k2=2) findqd(); if(k2=3) findzd(); if(k2=4) findbq(); if(k2=5) findbtime(); if(k2

16、=6) findetime(); if(k2=7) findjx(); if(k2=8) findprice(); if(k2=9) break; cout 菜单 2 endl;cout 1.按航班号查找endl; cout2.按起点站查找endl; cout3.按终点站查找endl; cout4.按班期查找endl; cout5.按起飞时间查找endl; cout6.按到达时间查找endl; cout7.按机型查找endl; cout8.按票价查找endl; cout9. 回到菜单 1endl; cout输入选择:endl;/菜单 2 int main()int k1;cou t * 航班信

17、息查询* endlendl; cou t菜单 1 endl;cout 1.创建一个航班表,并按航班号排序endl;cout2.输出航班表endl;cout3.查找航班endl;cout4.退出程序endlk1)if(k1=1) initb(); if(k1=2) printb(); if(k1=3) chazhao();if(k1=4) break;cout 菜单 1 endl;cout 1.创建一个航班表,并按航班号排序endl;cout2.输出航班表endl;cout3.查找航班endl;cout4.退出程序endl 新和啊-WGi 1*J-昴E呻 圭屯爲-5叩Mi Ifl-ORi -sM

18、Tjdjj aMElJitiZI A Atfta. 囲简;161F pni 换向勺El 15-14Iflffir IMPS:*-网 杞吋同口 i?ae 針港时阖-31SBHUin m八、程序的调试过程调试记录序号问题出处调试记录解决方法1void chazhao()编译有问题定义了新变量2查找不对修改void finde ti me();3不能正确调用修改 int main ()4不能返回原菜单调用出现问题九、实验总结在做实验航班查询的过程中,我对函数有了更深的理解,对函数的调用也 熟悉了许多。而且在学习的过程中又让我温习了冒泡排序法,对元素的查找也更 加的熟练。也让我认识到写算法对于编程很重要。做程序应由小到大。这样在做 程序的过程中找错误更加方便,效果更好。

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!