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

上传人:rrsccc 文档编号:9317185 上传时间:2021-02-18 格式:DOC 页数:10 大小:125KB
返回 下载 相关 举报
对飞机航班信息进行排序和查找.doc_第1页
第1页 / 共10页
对飞机航班信息进行排序和查找.doc_第2页
第2页 / 共10页
对飞机航班信息进行排序和查找.doc_第3页
第3页 / 共10页
对飞机航班信息进行排序和查找.doc_第4页
第4页 / 共10页
对飞机航班信息进行排序和查找.doc_第5页
第5页 / 共10页
点击查看更多>>
资源描述

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

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

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

3、d findjx() /按机型查找 void findprice() /按票价查找六、详细设计#includeusing namespace std;struct hangban char 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(in

4、t i=0;in;i+) /输入航班信息 cout输入第i+1个航班的信息endl; cout输入航班号endl; for(int j=0;jhi.kj; cout输入起点站hi.qd; cout输入终点站hi.zd; cout输入班期hi.bq; cout输入起飞时间hi.btime; cout输入到达时间hi.etime; cout输入机型hi.jx; cout输入票价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;

5、else if(hj.kl=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; v

6、oid findk() /通过航班号查询 int count=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 ;

7、couthi.qd ; couthi.zd ; couthi.bq ; couthi.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

8、; 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 findzd() /通过终点站查找 int count=0; coutk; for(int i=0;in;i+) if(k=hi.zd)cout第i+1个航班是要查找的航班endl;count+; cout第i+1个航班的信息endl;

9、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 findbq() /通过班期查找 int count=0; coutk; for(int i=0;in;i+) if(k=hi.bq) cout第i+1个航班是

10、要查找的航班endl;count+; 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; if(count=0) cout没有符合要求的航班endlendl;void findbtime() /通过起飞时间查找 int count=0; coutk;

11、 for(int i=0;in;i+) if(k=hi.btime) 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 ; couthi.btime ; couthi.etime ; couthi.jx ; couthi.price ; coutendl; if(count=0) cout没有符合要求的航班endlendl

12、;void findetime() /通过到达时间查找 int count=0; coutk; for(int i=0;in;i+) if(k=hi.etime) 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 ; couthi.btime ; couthi.etime ; couthi.jx ; couthi.pric

13、e ; coutendl; if(count=0) cout没有符合要求的航班endlendl;void findjx() /通过机型查找 int count=0; coutk; for(int i=0;in;i+) if(k=hi.jx) 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 ; couthi.btime ;

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

15、i.qd ; couthi.zd ; couthi.bq ; couthi.btime ; couthi.etime ; couthi.jx ; couthi.price ; coutendl; if(count=0) cout没有符合要求的航班endlendl;void chazhao() /查找信息 cout 菜单2 endl; cout1.按航班号查找endl; cout2.按起点站查找endl; cout3.按终点站查找endl; cout4.按班期查找endl; cout5.按起飞时间查找endl; cout6.按到达时间查找endl; cout7.按机型查找endl; cout8.

16、按票价查找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=6) findetime(); if(k2=7) findjx(); if(k2=8) findprice(); if(k2=9) break; cout 菜单2 endl; cout1.按航班号查找endl; cout2.按起点站查找endl; cout3.按终点站查找endl; cout4.按班期查找end

17、l; cout5.按起飞时间查找endl; cout6.按到达时间查找endl; cout7.按机型查找endl; cout8.按票价查找endl; cout9.回到菜单1endl; cout输入选择:endl;/菜单2 int main() int k1; cout*航班信息查询*endlendl; cout菜单1 endl; cout1.创建一个航班表,并按航班号排序endl; cout2.输出航班表endl; cout3.查找航班endl; cout4.退出程序endlk1) if(k1=1) initb(); if(k1=2) printb(); if(k1=3) chazhao();

18、 if(k1=4) break; cout 菜单1 endl; cout1.创建一个航班表,并按航班号排序endl; cout2.输出航班表endl; cout3.查找航班endl; cout4.退出程序endl输入选择:;/菜单1 七、使用说明、测试分析及结果1、测试结果与分析; 八、程序的调试过程调试记录序号问题出处调试记录解决方法1void chazhao()编译有问题定义了新变量2查找不对修改void findetime();3不能正确调用修改int main()4不能返回原菜单调用出现问题九、实验总结 在做实验航班查询的过程中,我对函数有了更深的理解,对函数的调用也熟悉了许多。而且在学习的过程中又让我温习了冒泡排序法,对元素的查找也更加的熟练。也让我认识到写算法对于编程很重要。做程序应由小到大。这样在做程序的过程中找错误更加方便,效果更好。

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

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1