1 / 13
文档名称:

数据结构航空客运订票系统.docx

格式:docx   大小:102KB   页数:13页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

数据结构航空客运订票系统.docx

上传人:guoxiachuanyue012 2022/11/24 文件大小:102 KB

下载得到文件列表

数据结构航空客运订票系统.docx

文档介绍

文档介绍:该【数据结构航空客运订票系统 】是由【guoxiachuanyue012】上传分享,文档一共【13】页,该文档可以免费在线阅读,需要了解更多关于【数据结构航空客运订票系统 】的内容,可以使用淘豆网的站内搜索功能,选择自己适合的文档,以下文字是截取该文章内的部分文字,如需要获得完整电子版,请下载此文档到您的设备,方便您编辑和打印。航空客运订票系统
程序要求:
1、问题描述航空客运订票的业务活动包括:查询航线、客票预订和办理退票等。设计一个航空客运订票系统,以使上述业务可以借助计算机完成。
2、要求
1)每条航线所涉及的信息有:终点站名、航班号、飞机号、飞行周日(星期几)、乘员定额、余票量、已订票的客户名单(包括名字、订票量、舱位等级1、2、3)以及等候替补的客户名单;
2)系统实现的功能如下:
通过此系统可以实现如下功能:录入:可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定)
查询:可以查询某个航线的情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班是否满仓);可以输入起飞抵达城市,查询飞机航班情况;订票:(订票情况可以存在一个数据文件中,结构自己设定)可以订票,如果该航班已经无票,可以提供相关可选择航班;
退票:可退票,退票后修改相关数据文件;客户资料有姓名,证件号,订票数量及航班情况,订单要有编号。
修改航班信息:当航班信息改变可以修改航班数据文件存储结构:航线的所有信息存储在一个结构体中,增加,查询,订票,退票等操作按队列的操作来实现。
程序流程图:
详细代码:
#include<>
#include<>
#include<>
#include<>
#definem4//3架飞机
#definen5//每架飞机5张票
structnode
{charname[21];
charid[21];
intseat,plane,date;
node*next,*pre;
};
structwait
{
charname[21];
charid[21];
charphone[8];
intseat,plane,date,count;
wait*next,*pre;
};
structpiao
{
intseat[n+1];
};
voidmakenull();
voidmakenull_piao();
voidmakenull_information();
voidlist_menu();
voidlist_piao();
voidmakenull_wait();
voidlist_information();
voidplane_information(node*head);
voidbook();
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;
piaoa[m];
voidmain()
{
makenull();
do
{list_menu();
cout<<endl<<"chooseanoperation:";cin>>c;
if(c!='6')
switch(c)
case'0':case'1':case'2':case'3':case'4':case'5':default:
show_wait();break;{list_piao();book();}break;search_delete(1);break;list_piao();break;list_information();break;search_delete(0);break;
break;
}
}while(c!='6');cout<<"ExitSystem";
}
voidmakenull()
{
}
voidlist_menu()
{cout<<endl<<"";cout<<endl<<"cout<<endl<<"
makenull_piao();makenull_information();makenull_wait();
cout<<endl<<"
*

*";
cout<<endl<<"
*

*";
cout<<endl<<"
*

*";
cout<<endl<<"
*

*";
cout<<endl<<"
*

*";
cout<<endl<<"
*

*";
cout<<endl<<"
*

*";
菜单";
11^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx11.
cout<<endl<<"cout<<endl<<"";
*1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1**1*tt^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx^Tx11.
}
voidmakenull_piao()
{
FILE*fp;
inti;
if((fp=fopen("","r"))==NULL)
{
fp=fopen("","w");
for(i=1;i<=m-1;i++)
fwrite(&a[i],sizeof(piao),1,fp);fclose(fp);
fp=fopen("","r");
}
for(i=1;i<=m-1;i++)fread(&a[i],sizeof(piao),1,fp);
fclose(fp);
}
voidmakenull_information()
{
node*r;
FILE*fp;
inti,j,sum;
sum=a[1].seat[0]+a[2].seat[0]+a[3].seat[0];fp=fopen("","r");head1=newnode;
head2=newnode;
head3=newnode;
head1->pre=NULL;head1->next=NULL;head2->pre=NULL;head2->next=NULL;head3->pre=NULL;head3->next=NULL;
q=head1;
for(i=1;i<=sum;i++)
{
j=0;
r=newnode;
fread(r,sizeof(node),1,fp);q->next=r;r->pre=q;
r->next=NULL;
q=q->next;
fclose(fp);
if(i==a[1].seat[0]+1){head2->next=q;q->pre->next=NULL;q->pre=head2;
}if(i==a[1].seat[0]+a[2].seat[0]+1){head3->next=q;q->pre->next=NULL;q->pre=head3;
}}
}voidmakenull_wait()
{
wait*tempw;FILE*fp;tempw=newwait;inti;
if((fp=fopen("","r"))==NULL){
fp=fopen("","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("","r");fread(wait_head,sizeof(wait),1,fp);
for(i=1;i<=wait_head->count;i++){
fread(tempw,sizeof(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(a[i].seat[0]!=n)
{
coutvvendlvv"第"vvivv"架飞机剩余的票:"vvendl;
for(j=1;j<=n;j++)
if(a[i].seat[j]==0)coutvv""vvj;
coutvvendl;
}
elsecoutvvendlvv"The"vvivv"planeisfull!"vvendlvvendl;
}
}
voidlist_information()
{
intx;
do{coutvvendlvv"显示哪架飞机的信息?";cin>>x;coutvvendl;}while(xvlIIx>=m);coutvvendlvv"第"vvxvv"架飞机的信息如下"vvendl;
if(x==l)plane_information(headl);
if(x==2)plane_information(head2);
if(x==3)plane_information(head3);
}
voidplane_information(node*head)
{
node*q;
charch;
intx=0;
if(head!=NULL&&head->next!=NULL)
q=head->next;
else{
q=NULL;
coutvv"飞机空,无预订票!"vvendl;
}while(q!=NULL)
{
q->date=q->plane;
coutvv"日期:"vvq->datevvendl;coutvv"座位号:"vvq->seatvvendl;
coutvv"姓名:"vvq->name;coutvvendlvv"ID号:"vvq->id;
q=q->next;x++;if(x%3==0)ch=getch();
}
coutvvendl;
}
voidbook()
{
inti,j,p;
coutvvendlvv"请选择地点:(1、2、3)";
do{
cin>>i;
if(i<1||i>=m){
coutvvendlvv"****超出范围!****"vvendlvv"请重新输入:”;
}
else
{coutvvendlvv"你要订的是到"vvivv"地的飞机"vvendl;coutvvendlvv"第"vvivv"架飞机剩余的票:"vvendl;
for(p=1;pv=n;p++)
if(a[i].seat[p]==0)coutvv""vvp;
coutvvendl;
break;}
}while(1);
coutvvendlvv"请选择座位号:";
do{
cin>>j;
if(jv1||j>n){
coutvvendlvv"****超出范围!****"vvendlvv"请重新输入:”;
}
else
{
q->date=i;coutvvendlvv"您的订票日期:"vvq->datevvendl;
break;
}
}while(1);
if(a[i].seat[j]==0){
a[i].seat[j]=1;
coutvvendl;
a[i].seat[0]++;
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
{coutvvendlvv"****对不起,该座位已被预订,您被安排到订票等候队列****"vvendl;add_wait(i,j);
voidadd_wait(intx,inty)
{
wait*tempw;tempw=newwait;tempw->next=NULL;
coutvv"请输入个人信息"vvendl;cout<<endl<<"*************"<<endl;
coutv<"姓名:";cin>>tempw->name;coutvv"ID号:";cin>>tempw->id;coutvv"电话:";cin>>tempw->phone;tempw->seat=y;
tempw->plane=x;wait_end->next=tempw;tempw->pre=wait_end;
wait_end=wait_end->next;coutvvendlvv"****正在排队等候****"vvendl;wait_head->count++;
write_to_file();
}
voidshow_wait()
{
wait*tempw;tempw=wait_head->next;
if(tempw==NULL)coutvvendlvv'排队中没有人!"vvendl;while(tempw!=NULL)
{
coutvvtempw->namevv"-";tempw=tempw->next;
}
}
voidadd_information(node*head,intx,inty)
{
node*temp;
temp=newnode;temp->pre=NULL;temp->next=NULL;
coutvv"请输入个人信息"vvendl;coutvvendlvv"*************"vvendl;
coutvv"姓名:";cin>>temp->name;coutvv"ID号:";cin>>temp->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();cout<<endl<<"****订票成功****"<<endl;
}
voidsearch_delete(intx)
{
node*p,*q,*r;
wait*tempw,*tempw2,*tempw3;
intstep=1,t1,t2,i;
charch;
p=newnode;
tempw=newwait;
tempw2=newwait;
tempw3=newwait;
q=head1;
coutvvendlvv"请输入个人信息"vvendl;cout<<"*************"<<endl;coutvvendlv<"姓名:";cin>>p->name;
do{
q=q->next;
if((q!=NULL)&&
(comp(q,p)))
{
coutvvendl;
q->date=q->plane;coutvv"Located!"vvendl;
coutvv"****************";coutvvendlvv"姓名:"vvq->name;coutvvendlvv"ID号:"vvq->id;coutvvendlvv"座位号:"vvq->seat;coutvvendlvv"班机号:"vvq->plane;coutvvendlvv"日期:"vvq->datevvendl;
if(x==1){
coutvv"删除该纪录?[Y/N]";cin>>ch;
if(ch=='Y'||ch=='y'){
t1=q->plane;t2=q->seat;a[t1].seat[t2]=0;a[t1].seat[0]--;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;i<wait_head->count;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);
coutvvendlvv,等候的人中有可以订票的了:"vvendl;cout<<endl<<"姓名:"<<tempw->name;coutvvendlvv"ID号:"vvtempw->idvvendl;a[t1].seat[0]++;
a[t1].seat[t2]=1;
if(tempw->plane==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;elsetempw->next->pre=tempw2;
delete(tempw);
wait_head->count--;
write_to_file();
coutvvendlvv"等候的"vvtempw3->namevv"已经成功订票,已经由电话"vvtempw3->phonevv"通知了"vvendl;
break;
}
}
}
}continue;
}
else
{