数据结构课程机场订票_第1页
数据结构课程机场订票_第2页
数据结构课程机场订票_第3页
数据结构课程机场订票_第4页
数据结构课程机场订票_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、航空客运订票系统程序要求:1、问题描述航空客运订票的业务活动包括:查询航线、客票预订和办理退票等。设计一个航空客运订票系统,以使上述业务可以借助计算机完成。2、要求1)每条航线所涉及的信息有:终点站名、航班号、飞机号、飞行周日(星期几)、乘员定额、余票量、已订票的客户名单(包括名字、订票量、舱位等级1、2、3)以及等候替补的客户名单;2)系统实现的功能如下:通过此系统可以实现如下功能:录入:可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定)查询:可以查询某个航线的情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班是否满仓);可以输入起飞抵达城市

2、,查询飞机航班情况;订票:(订票情况可以存在一个数据文件中,结构自己设定)可以订票,如果该航班已经无票,可以提供相关可选择航班;退票:可退票,退票后修改相关数据文件;客户资料有姓名,证件号,订票数量及航班情况,订单要有编号。修改航班信息:当航班信息改变可以修改航班数据文件存储结构:航线的所有信息存储在一个结构体中,增加,查询,订票,退票等操作按队列的操作来实现。程序流程图:退票成功详细代码:#inelude#include#inelude#inelude#definem43架飞机#definen5/每架飞机5张票structnodecharname21;charid21;intseat,pla

3、ne,date;node*next,*pre;structwaitcharname21;charid21;charphone8;intseat,plane,date,count;wait*next,*pre;structpiaointseatn+1;voidmakenu11();voidmakenull_piao();voidmakenullnformation();voidlist_menu();voidlist_piao();voidmakenull_wait();voidlist_information();voidplane_information(node*head);voidboo

4、k();voidadd_information(node*head,intx,inty);voidadd_wait(intx,inty);voidsearch_delete(intx);voidwrite_to_file();voidshow_wait();boolcomp(node*x,node*y);node*head1,*head2,*head3,*q;wait*wait_head,*wait_end;charc;piaoam;voidmain()makenull();dolist_menu();coutendlc;if(c!=6)switch(c)case0:show_wait();b

5、reak;case1:list_piao();book();break;case2:search_delete(1);break;case3:list_piao();break;case4:list_information();break;case5:search_delete(0);break;default:break;while(c!=6);coutExitSystem;voidmakenull()makenull_piao();makenull_information();makenull_wait();voidlist_menu()*0.查看排队情况*n*1.订票*n*2.退票*n*

6、3.查看剩余票*n*4.查看飞机信息*n*5.查看乘客信息*6.退出*n菜单;*coutendl;coutendlcoutendlcoutendlcoutendlcoutendlcoutendlcoutendlcoutendlcoutendlcoutendlcoutendl;voidmakenull_piao()FILE*fp;inti;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);f

7、or(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;voidmakenull_wait(

8、)wait*tempw;FILE*fp;tempw=newwait;inti;if(fp=fopen(wait.txt,r)=NULL)fp=fopen(wait.txt,w);fclose(fp);wait_end=newwait;wait_head=newwait;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,sizeo

9、f(wait),1,fp);wait_end-next=tempw;tempw-pre=wait_end;tempw-next=NULL;wait_end=tempw;voidlist_piao()inti,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)coutj;coutendl;elsecoutendlTheiplaneisfull!endlendl;voidlist_information()intx;docoutendlx;coutendl;while(x=m)

10、;coutendl第x架飞机的信息如下next!=NULL)q=head-next;elseq=NULL;cout飞机空,无预订票!endl;while(q!=NULL)endl;endl;coutendldate=q-plane;cout日期:dateendl;cout座位号:seatendl;cout姓名:name;coutendlID号:id;q=q-next;x+;if(x%3=0)ch=getch();coutendl;voidbook()inti,j,p;coutendli;if(i=m)coutendl*超出范围!*endl请重新输入:;elsecoutendl你要订的是到i地的

11、飞机endl;coutendl第i架飞机剩余的票:endl;for(p=1;p=n;p+)if(ai.seatp=0)coutp;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_informa

12、tion(head3,3,j);elsecoutendl*对不起,该座位已被预订,您被安排到订票等候队列*next=NULL;cout请输入个人信息endl;coutendlcoutendlendl;couttempw-name;couttempw-id;couttempw-phone;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+;

13、write_to_file();voidshow_wait()wait*tempw;tempw=wait_head-next;if(tempw=NULL)coutendl排队中没有人!while(tempw!=NULL)coutnamenext;voidadd_information(node*head,intx,inty)node*temp;temp=newnode;pre=NULL;temp-next=NULL;cout请输入个人信息endl;coutendlcoutendlendl;couttemp-name;couttemp-id;couttemp-name;couttemp-id;t

14、emp-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*订票成功*next!=NULL)head-next-pre=temp;head-next=temp;write_to_file();coutendl*订票成功*endl;voidsearch_delete(intx)node*p,*q,*r;wait*tempw,*tempw2,*tempw3;intstep=1,t1,t2,

15、i;charch;p=newnode;tempw=newwait;tempw2=newwait;tempw3=newwait;q=head1;coutendl请输入个人信息endl;coutendl;coutendlp-name;doq=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)

16、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-ph

17、one,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;el

18、setempw-next-pre=tempw2;delete(tempw);wait_head-count-;write_to_file();coutendl等候的name已经成功订票,已经由电话phone通知了endl;break;continue;elseif(q=NULL)step+;if(step=2)q=head2;if(step=3)q=head3;if(step=4)coutendlnamei!=q-namej)&(p-namei!=0)i+;if(p-namei=0)return(false);break;elsek=i;while(p-namek=q-namej)&(q-namej!=0)k+;j+;if(q-namej=0)return(true);elsej=0;i+;while(q-namej!=0)&(p-namei!=0);return(false);voidwrite_to_file()FILE*fp;inti,j;intxm;node*p;wait*tempw;tempw=newwait;tempw=wait_head;fp=fopen(piao.dat,w);for(i=1;i=m-1;i+)fwrite(&ai,sizeof(piao),1,fp);fc

温馨提示

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

评论

0/150

提交评论