已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
数据结构 课程设计数据结构课程设计航空订票系统学院:计算机科学与技术学院班级:网络工程081姓名:杨阳学号:0813072011一、需求分析1).每条航线所涉及的信息有:终点站名、航班号、飞机号、飞行日期、定票量、已定票的乘客名单、票价。2).作为示意系统,所有数据可以只放在内存中。3).系统能实现的操作和功能如下:a) 查询航线:能根据乘客提出的终点站名输出下列信息:航班号、所属航空公司、班机号、飞行日期、起飞时间、目的机场、到达时间。b) 承办售票业务c) 承办定票业务d) 承办退票业务二、设计概要1、抽象数据类型的定义如下:ADT Schedule数据对象:D=ei| i=1,2,3,n;n0;eiSchedule 数据关系:R1=ei-1, ei|ei-1,ei表示ei-1和ei之间有先后顺序关系基本操作:Schedule *OutFile(fstream &outfile); 操作结果:打开文本文件dipiao.txt,把文件中的数据送到结构体数组中。bool Search_airnum(Schedule *P,Schedule &plane,char airnum); 初始条件:结构体数组P存在 操作结果:按照输入的航班号进行查找,并显示。bool Search_Airport(Schedule *P,Schedule plane,int &num,char portname); 初始条件:结构体数组P存在 操作结果:按照输入的时间和目的机场进行查找,并显示。 ADT Schedule2、抽象数据类型队列的定义如下:ADT LinkQueue数据对象:D=ei| i=1,2,3,n;n0;eiLinkQueue 数据关系:R1=ei-1, ei|ei-1,ei表示ei-1和ei之间有先后顺序关系基本操作:bool InitQueue(LinkQueue &Q); 操作结果:创建一个空的队列Q。bool DestroyQueue(LinkQueue &Q); 初始条件:队列Q存在 操作结果:销毁队列Q,Q不再存在。bool EnQueue(LinkQueue &Q,CSNode e); 初始条件:队列Q存在 操作结果:插入元素e为Q的新的队尾元素。bool ClearQueue(LinkQueue &Q); 初始条件:队列Q存在 操作结果:清空队列Q。bool QueueEmpty(LinkQueue Q); 初始条件:队列Q存在 操作结果:若队列为空,则返回true,否则返回false。bool DeQueue(LinkQueue &Q,CSNode &e); 初始条件:队列Q存在 操作结果:删除Q的队头元素,并用e返回其值,并返回true。int QueueLength(LinkQueue Q); 初始条件:队列Q存在 操作结果:返回队列Q的长度。bool GetHead(LinkQueue Q,CSNode &e); 初始条件:队列Q存在 操作结果:用e返回队首元素,并返回true。 ADT LinkQueue三、详细设计1、程序流程图主界面查询系统订票系统退票系统是否有票?没有票有票售票四、调试分析1、该程序的主要存储结构是数组,其次有队列,队列主要用来存放定票人的信息。2、进行查找的时候,能够根据输入的时间区间进行模糊查找,并且把找到的所有符合条件的航班显示出来。3、对输入的错误信息给出警告或提示,对一次操作的完成也给出相应的提示。五、测试结果图1 主界面图2 订票界面图3 退票界面图4 查飞机信息界面图5 查乘客信息界面六、总结和体会 通过这次的数据结构课程设计,发现了自己学习还有很多不足的地方,对于这个航空订票系统,有很多的漏洞,包括C+语言上还有很多可以修改的地方。在系统的设计上也和真实航空售票系统有很多差异,例如买票不是依次顺序卖票的,而是先到者选票,这个在本系统中没有实现好,只能说是个很粗糙的系统,还有很多地方值得我去修改。短短几天,能成功调试成功,我感到很高兴,毕竟面对这个相对于以往更复杂的系统,我做了出来,而且基本满足设计需求。编程是个非常辛苦非常快乐的事情,希望在未来我能更加灵活运用C+语言。九、附:源程序#include #include #include #include #define m 4 /3架飞机#define n 5 /每架飞机5张票struct node char name21; char id21; int seat,plane,date; node *next,*pre;struct wait char name21; char id21; char phone8; int seat,plane,date,count; wait *next,*pre;struct piao int seatn+1;void makenull(); void makenull_piao();void makenull_information();void list_menu();void list_piao();void makenull_wait();void list_information();void plane_information(node *head);void book();void add_information(node *head,int x,int y);void add_wait(int x,int y);void search_delete(int x);void write_to_file();void show_wait();bool comp(node *x,node*y);node *head1,*head2,*head3,*q;wait *wait_head,*wait_end;char c;piao am;void main() makenull(); do list_menu(); coutendlc; if (c!=6) switch(c) case 0 : show_wait();break; case 1 : list_piao();book();break; case 2 : search_delete(1);break; case 3 : list_piao();break; case 4 : list_information();break; case 5 : search_delete(0);break; default : break; while(c!=6); coutExit System ;void makenull() makenull_piao(); makenull_information(); makenull_wait();void list_menu() coutendl; coutendl 航空订票系统; coutendl *; coutendl & 0 . 查看排队情况 &; coutendl & 1 . 订票 &; coutendl & 2 . 退票 &; coutendl & 3 . 查看剩余票 &; coutendl & 4 . 查看飞机信息 &; coutendl & 5 . 查看乘客信息 &; coutendl & 6 . 退出 &; coutendl *; coutendl;void makenull_piao() FILE *fp; int i; if(fp=fopen(piao.dat,r) = NULL ) fp=fopen(piao.dat,w); for (i=1;i=m-1;i+) fwrite(&ai,sizeof(piao),1,fp); fclose(fp); fp=fopen(piao.dat,r); for(i=1;ipre=NULL; head1-next=NULL; head2-pre=NULL; head2-next=NULL; head3-pre=NULL; head3-next=NULL; q=head1; for(i=1;inext=r; r-pre=q; r-next=NULL; q=q-next; fclose(fp); if(i=a1.seat0+1) head2-next=q; q-pre-next=NULL; q-pre=head2; if(i=a1.seat0+a2.seat0+1) head3-next=q; q-pre-next=NULL; q-pre=head3; void makenull_wait() wait *tempw; FILE *fp; tempw=new wait; int i; if(fp=fopen(wait.txt,r) =NULL ) fp=fopen(wait.txt,w); fclose(fp); wait_end=new wait; wait_head=new wait; wait_end-next=NULL; wait_end-pre=NULL; wait_head=wait_end; wait_head-count=0; fp=fopen(wait.txt,r); fread(wait_head,sizeof(wait),1,fp); for(i=1;icount;i+) fread(tempw,sizeof(wait),1,fp); wait_end-next=tempw; tempw-pre=wait_end; tempw-next=NULL; wait_end=tempw; void list_piao() int i,j; for(i=1;i=m-1;i+) if(ai.seat0!=n) coutendl第 i 架飞机剩余的票 :endl; for(j=1;j=n;j+) if (ai.seatj=0) cout j; coutendl; else coutendlThe i plane is full !endlendl; void list_information() int x; do coutendlx;coutendl;while(x=m); coutendl第 x 架飞机的信息如下 next!=NULL) q=head-next; else q=NULL; cout飞机空,无预订票 !endl; while(q!=NULL) coutendl*date=q-plane; cout日期 :dateendl; cout座位号 : seatendl; cout姓名 : name; coutendlID 号 : id; q=q-next;x+; if (x % 3 =0) ch=getch(); coutendl;void book() int i,j,p; coutendli; if (i=m) coutendl* 超出范围!*endl请重新输入:; else coutendl你要订的是到i地的飞机endl; coutendl第 i 架飞机剩余的票 :endl; for(p=1;p=n;p+) if (ai.seatp=0) cout p; coutendl; break; while(1); coutendlj; if (jn) coutendl* 超出范围!*endldate=i; coutendl您的订票日期 : dateendl; break; while(1); if (ai.seatj=0) ai.seatj=1; coutendl; ai.seat0+; if(i=1) add_information(head1,1,j); if(i=2) add_information(head2,2,j); if(i=3) add_information(head3,3,j); else coutendl* 对不起,该座位已被预订,您被安排到订票等候队列 *next=NULL; cout请输入个人信息endl; coutendl*endl; couttempw-name; couttempw-id; couttempw-phone; tempw-seat=y; tempw-plane=x; wait_end-next=tempw; tempw-pre=wait_end; wait_end=wait_end-next; coutendl* 正在排队等候 *count+; write_to_file();void show_wait() wait *tempw; tempw=wait_head-next; if (tempw=NULL) coutendl排队中没有人!endl; while(tempw!=NULL) coutnamenext; void add_information(node *head,int x,int y) node *temp; temp=new node; temp-pre=NULL; temp-next=NULL; cout请输入个人信息endl; coutendl*endl; couttemp-name; couttemp-id; temp-seat=y; temp-plane=x; temp-next=head-next; temp-pre=head; if (head-next!=NULL) head-next-pre=temp; head-next=temp; write_to_file(); coutendl* 订票成功 *endl;void search_delete(int x) node *p,*q,*r; wait *tempw,*tempw2,*tempw3; int step=1,t1,t2,i; char ch; p=new node; tempw=new wait; tempw2=new wait; tempw3=new wait; q=head1; coutendl请输入个人信息endl; cout*endl; coutendlp-name; do q=q-next; if ( (q!=NULL) & (comp(q,p) ) coutdate=q-plane; coutLocated!endl; cout*; coutendl姓名 : name; coutendlID号 : id; coutendl座位号 : seat; coutendl班机号 : plane; coutendl日期 : dateendl; if (x=1) coutch; if (ch=Y | ch=y) t1=q-plane; t2=q-seat; at1.seatt2=0; at1.seat0-; r=q;q=q-pre; r-pre-next=r-next; if(r-next!=NULL) r-next-pre=r-pre; delete(r); cout* 记录删除成功 ! *; write_to_file(); tempw=wait_head; for(i=0;icount;i+) tempw=tempw-next; if(tempw=NULL) break; if(tempw-plane=t1) & (tempw-seat=t2) strcpy(tempw3-name,tempw-name); strcpy(tempw3-phone,tempw-phone); coutendl等候的人中有可以订票的了:endl; coutendl姓名 : name; coutendlID号 : idplane=1) add_information(head1,1,tempw-seat); if(tempw-plane=2) add_information(head2,2,tempw-seat); if(tempw-plane=3) add_information(head3,3,tempw-seat); tempw2=tempw-pre; tempw2-next=tempw-next; if(tempw-next=NULL) wait_end=tempw2; else tempw-next-pre=tempw2; delete(tempw); wait_head-count-; write_to_file(); coutendl等候的name已经成功订票,已经由电话phone通知了endl; break; continue; else if (q=NULL) step+; if(step=2) q=head2; if(st
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 光伏组件施工安全培训
- 炼铁厂电仪考试题库及答案
- 抗感染药物给药方案设计
- 先导式安全阀培训课件
- 2024年高考地理一轮复习(人教版)水循环
- 佳成核安全课件
- 高等数学二试卷及答案
- 《矿石分析》期末考试复习题库(含答案)
- 福尔摩斯题目及答案
- 企业安全管理百科培训课件
- 2024智慧矿山自动驾驶标杆企业案例研究
- 三年级上册数学母题解题技巧(共27类)
- 汽车构造与拆装课件 第一篇 安全与素养
- 老旧小区屋面防水维修施工方案
- 天水村文书考试题及答案
- 夜视仪基础知识培训课件
- 网吧安全生产工作方案
- 2025年警察招聘考试公安基础知识考试试题及参考答案
- 2025年贵州省贵阳市辅警(协警)招聘考试题库及答案
- 海南自贸港课件
- (正式版)DB33∕T 1431-2025 《公路固化土路基施工规范》
评论
0/150
提交评论