1、航空客运订票系统 程序要求: 1、 问题描述 航空客运订票得业务活动包括:查询航线、客票预订与办理退票等。设计一个航空客运订票系统,以使上述业务可以借助计算机完成。 2、 要求 1) 每条航线所涉及得信息有:终点站名、航班号、飞机号、飞行周日(星期几)、乘员定额、余票量、已订票得客户名单(包括名字、订票量、舱位等级1、2、3)以及等候替补得客户名单; 2) 系统实现得功能如下: 通过此系统可以实现如下功能: 录入:可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定) 查询:可以查询某个航线得情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折
2、扣,确定航班就是否满仓);可以输入起飞抵达城市,查询飞机航班情况; 订票:(订票情况可以存在一个数据文件中,结构自己设定)可以订票,如果该航班已经无票,可以提供相关可选择航班; 退票: 可退票,退票后修改相关数据文件;客户资料有姓名,证件号,订票数量及航班情况,订单要有编号。 修改航班信息:当航班信息改变可以修改航班数据文件 存储结构:航线得所有信息存储在一个结构体中,增加,查询,订票,退票等操作按队列得操作来实现。 程序流程图: Switch(1) 录入功能 请按次序输入航班号,飞机号,终点站,飞行日期,乘客总数,余票数等信息
3、
查询功能
通过目得地查询
Switch(1)
请输入要查询得目得地
Switch(2)
请输入要查询得航班号
通过航班号查询
Switch(2)
Switch(3)
订票功能
请输入您需要得订票数
订票成功
订票数<余票数
输入您定得票数
输入您得名字
退票功能
Switch(4)
订票数<余票数
退票成功
Switch(5)
退出系统
详细代码:
#include 〈iostream、h>
#include
4、clude 5、 wait *next,*pre;
};
struct piao
{
int seat[n+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 6、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 p(node *x,node*y);
node *head1,*head2,*head3,*q;
wait *wait_head,*wait_end;
char c;
piao a[m];
void main()
{
makenull();
do
{ list_menu();
7、cout〈 8、 case '4’ : list_information();break;
case ’5’ : search_delete(0);break;
default : break;
}
}while(c!='6’);
cout<〈"Exit System ";
}
void makenull()
{
makenull_piao();
makenull_information();
makenull_wait();
}
void list_menu() 9、
{ cout〈 10、out<<endl<<” * 4 、 查瞧飞机信息 *”;
cout<<endl〈〈" * 5 、 查瞧乘客信息 *";
cout<〈endl〈<" * 6 、 退出 *";
cout〈〈endl〈<" ************************";
cout〈<endl<<”";
}
void makenull_piao()
{
FILE *fp;
int i;
if((fp=fopen(”piao、dat","r")) == NULL ) 11、
{
fp=fopen("piao、dat”,”w");
for (i=1;i<=m-1;i++)
fwrite(&a[i],sizeof(piao),1,fp);
fclose(fp);
fp=fopen("piao、dat”,"r”);
}
for(i=1;i〈=m—1;i++)
fread(&a[i],sizeof(piao),1,fp);
fclose(fp);
}
void makenull_information()
{
12、
node *r;
FILE *fp;
int i,j,sum;
sum=a[1]、seat[0]+a[2]、seat[0]+a[3]、seat[0];
fp=fopen("information、dat”,"r”);
head1=new node;
head2=new node;
head3=new node;
head1—〉pre=NULL;
head1—>next=NULL;
head2->pre=NULL;
head2—〉next=NULL;
head3—>pre=NULL; 13、
head3->next=NULL;
q=head1;
for(i=1;i<=sum;i++)
{
j=0;
r=new node;
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->ne 14、xt=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;
}
}
}
void makenull_wait()
{
wait *tempw;
FILE *fp;
tempw=n 15、ew 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(" 16、wait、txt","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;
17、wait_end=tempw;
}
}
void list_piao()
{
int i,j;
for(i=1;i<=m-1;i++)
{
if(a[i]、seat[0]!=n)
{
cout<<endl<<"第 ”<〈i<〈" 架飞机剩余得票 :"<〈endl;
for(j=1;j〈=n;j++)
if (a[i]、seat[j]==0) cout<〈” "<〈j;
cout〈 18、dl;
}
else cout<<endl<〈"The "<<i<〈” plane is full !"〈〈endl< 19、 if(x==2) plane_information(head2);
if(x==3) plane_information(head3);
}
void plane_information(node *head)
{
node *q;
char ch;
int x=0;
if(head!=NULL && head->next!=NULL)
q=head-〉next;
else {
q=NULL;
cout<<”飞机空,无预订票 !”〈 20、 while(q!=NULL)
{
cout〈<endl〈〈”*******************”〈<endl;
q->date=q—〉plane;
cout〈<”日期 :"< 21、ch=getch();
}
cout<〈endl;
}
void book()
{
int i,j,p;
cout〈〈endl<<"请选择地点:(1、2、3) ";
do {
cin>〉i;
if (i〈1 || i>=m) {
cout〈<endl<〈"**** 超出范围!****"< 22、 cout< 23、ndl<<"**** 超出范围!****"<〈endl<<"请重新输入:";
}
else
{
q—〉date=i;
cout< 24、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
{ cout〈<endl<〈"**** 对不起,该座位已被预订,您被安排到订票等候队列 ****”< 25、w=new wait;
tempw->next=NULL;
cout〈<"请输入个人信息"<<endl;
cout〈<endl<<"*************"<<endl;
cout<〈"姓名 : ”;cin〉〉tempw-〉name;
cout<〈"ID号 : ";cin>>tempw—>id;
cout<〈"电话 :";cin>>tempw->phone;
tempw->seat=y;
tempw—>plane=x;
wait_end—>next=tempw;
tempw->pre=wai 26、t_end;
wait_end=wait_end->next;
cout〈 27、e<<” — ";
tempw=tempw—>next;
}
}
void add_information(node *head,int x,int y)
{
node *temp;
temp=new node;
temp—>pre=NULL;
temp-〉next=NULL;
cout〈〈”请输入个人信息"〈<endl;
cout〈〈endl<<”*************”<<endl;
cout〈<"姓名 : ";cin>>temp->name;
cout<<"ID号 : ";cin 28、>〉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< 29、mpw,*tempw2,*tempw3;
int step=1,t1,t2,i;
char ch;
p=new node;
tempw=new wait;
tempw2=new wait;
tempw3=new wait;
q=head1;
cout<<endl〈<”请输入个人信息”〈 30、 if ( (q!=NULL) &&
(p(q,p)) )
{
cout<〈endl;
q->date=q—>plane;
cout〈〈"Located!"〈<endl;
cout<<”****************”;
cout<<endl<〈"姓名 : ”<<q—〉name;
cout< 31、号 : "〈 32、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〈〈"**** 记录删除成功 ! 33、 ****";
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) & 34、& (tempw—>seat==t2))
{
strcpy(tempw3—>name,tempw—〉name);
strcpy(tempw3->phone,tempw-〉phone);
cout〈 35、e;
cout〈<endl<<"ID号 : ”<〈tempw-〉id<<endl;
a[t1]、seat[0]++;
a[t1]、seat[t2]=1;
if(tempw->plane==1) add_information(head1,1,tempw-〉seat);
if(tempw->plane==2) 36、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;
37、 else tempw—>next->pre=tempw2;
delete(tempw);
wait_head—>count-—;
write_to_file();
cout〈 38、
break;
}
}
}
}continue;
}
else
{
if (q==NULL)
{
step++;
if(step==2) q=head2;
if(step==3) 39、 q=head3;
if(step==4) {cout〈 40、) i++;
if (p—〉name[i] == '\0') {return(false);break;}
else
{
k=i;
while ( (p-〉name[k] == q->name[j]) && (q-〉name[j]!='\0’) ) {k++;j++;}
if (q—>name[j]=='\0') return(true);
else
{
j=0;
41、 i++;
}
}
}while( (q->name[j]!='\0’) && (p-〉name[i] != '\0') );
return(false);
}
void write_to_file()
{
FILE *fp;
int i,j;
int x[m];
node *p;
wait *tempw;
tempw=new wait;
tempw=wait_head;
fp=fopen("piao、dat",”w");
42、 for (i=1;i<=m—1;i++)
{
fwrite(&a[i],sizeof(piao),1,fp);
}
fclose(fp);
fp=fopen("information、dat","w”);
x[0]=0;x[1]=a[1]、seat[0];
for(i=0,j=1;j<=m-1;j++) {i=i+a[j]、seat[0];x[j]=a[j]、seat[0]+x[j-1];}
j=1;p=head1-〉next;
for(j=1;j〈=i;j++)
{
43、 if(j==x[1]+1) p=head2—>next;
if(j==x[2]+1) p=head3-〉next;
if(p==NULL)break;
fwrite(p,sizeof(node),1,fp);
p=p->next;
}
fclose(fp);
fp=fopen(”wait、txt","w");
for(j=0;j<=wait_head—>count;j++)
{
if(tempw==NULL)break;
fwrite(tempw,sizeof(wait),1,fp);
tempw=tempw—>next;
}
fclose(fp);
}
seat;
cout<<endl<<"班机号 : "<<q—>plane;
cout<






