#include <iostream.h>#include <string.h>void FlightInsert(); //增加路线void FlightDelete();//删除路线void FlightLookup();//航班查询void FlightRework();//航班路线修改void FlightBuyticket();//买票void FlightCancelticket();//取消订票void Flightclean();//清空void MainMenu();//主函数void Display();//显示订票信息typedef struct Customer //已定票乘客信息{char Name[10]; //int Amount; //定票数int Level; //舱位等级int SeatNum; //座位号char FlightNum[10]; //所定航班号struct Customer *next;}Customer;typedef struct Replace //侯补乘客信息{char Name[10]; //姓名eint Amount; //定票数int Level; //舱位等级char FlightNum[10]; //所定航班号struct Replace *next;}Replace;typedef struct Flight //航班路线信息{char From[10]; //起点站名char Des[10]; //终点站名char FlightNum[10]; //航班号char PlaneNum[10]; //航班char Week[20]; //飞机周日int Ration; //乘员定额int FreeTicket; //剩余票数float Price[3]; //票价int ReplacePas; //候补乘客数Replace *ReplName; //该航班的候补乘客名单Customer *CustName; //该航班的已定票乘客名单struct Flight *next; //指示下一航班路线结点}Flight,*PFlight;int Ration=0; //乘客总数Flight *head; //建立航班路线头结点Flight *rear; //建立航班路尾结点Customer *Cusrear;Replace *Reprear;void MainMenu(){int i=0;while (i!=8){cout<<endl;cout<<" ***************【欢迎使用航空订票系统】***************"<<endl;cout<<""<<endl;cout<<" ***************【按1】增加航班路线***************"<<endl;cout<<""<<endl;cout<<" ***************【按2】查询航班路线***************"<<endl;cout<<""<<endl;cout<<" ***************【按3】修改航班路线***************"<<endl;cout<<""<<endl;cout<<" ***************【按4】预订飞机票***************"<<endl;cout<<""<<endl;cout<<" ***************【按5】退订飞机票***************"<<endl;cout<<""<<endl;cout<<" ***************【按6】清空系统***************"<<endl;cout<<""<<endl;cout<<" ***************【按7】已订票名单***************"<<endl;cout<<""<<endl;cout<<" ***************【按8】退出系统***************"<<endl;cout<<""<<endl;cout<<" *提示:当前为主菜单"<<endl;cin>>i;switch(i){case 1:FlightInsert();break; //增加航班路线case 2:FlightLookup();break; //查询航班路线case 3:FlightRework();break; //修改航班路线case 4:FlightBuyticket();break; //预订飞机票case 5:FlightCancelticket();break; //退订飞机票case 6:Flightclean();break; //清空系统case 7:Display();break;case 8:;break;default:cout<<"*提示:抱歉,请选择正确的操作!"<<endl;cout<<endl;cout<<endl;break;}}}void FlightInsert() //航班录入{/*int i=2;while(i!=1){*/Flight *p;p=new Flight;cout<<"****正在设定新的路线****"<<endl;cout<<endl;cout<<"1.请设定起点站名:"<<endl;cin>>p->From;cout<<"2.请设定终点站名:"<<endl;cin>>p->Des;cout<<"3.请设定航班号:"<<endl;cin>>p->FlightNum;cout<<"4.请设定飞机号:"<<endl;cin>>p->PlaneNum;cout<<"5.请设定飞行周日:"<<endl;cin>>p->Week;cout<<"6.请设定乘员定额:"<<endl;cin>>p->Ration;p->FreeTicket=p->Ration;cout<<"7.请设定一等舱的价格:"<<endl;cin>>p->Price[0];cout<<"8.请设定二等舱的价格:"<<endl;cin>>p->Price[1];cout<<"9.请设定三等舱的价格:"<<endl;cin>>p->Price[2];p->ReplName=new Replace;p->CustName=new Customer;p->CustName->next=NULL;p->ReplName->next=NULL;p->ReplacePas=0;rear->next=p;rear=p;rear->next=NULL;cout<<"设置成功!"<<endl;cout<<"***********************"<<endl;cout<<endl;/*cout<<"【按1】返回主菜单【按2】继续"<<endl;cin>>i;}*/}void FlightLookup() //查询航班号{Flight *p,*q;char FlightNum[10];p=head;int i=0;while (i!=1){cout<<"请输入需要查询的航班号:"<<endl;cin>>FlightNum;while (p->next && strcmp(p->next->FlightNum,FlightNum)){p=p->next;}q=p->next;if (q==NULL){cout<<"*提示:对不起,不存在此航班号,请核实您的信息!"<<endl;}else{cout<<"以下是您所查的车次信息:"<<endl;cout<<"************************"<<endl;cout<<"* 1.航班号:"<<q->FlightNum<<endl;cout<<"* 2.飞机号:"<<q->PlaneNum<<endl;cout<<"* 3.起点站:"<<q->From<<endl;cout<<"* 4.目的地:"<<q->Des<<endl;cout<<"* 5.飞机周日:"<<q->Week<<endl;cout<<"* 6.成员定额:"<<q->Ration<<endl;cout<<"* 7.剩余票数:"<<q->FreeTicket<<""<<endl;cout<<"* 8.候补乘客数:"<<q->ReplacePas<<"人"<<endl;cout<<"* 9.一等舱的价格:"<<q->Price[0]<<"元"<<endl;cout<<"* 10.二等舱的价格:"<<q->Price[1]<<"元"<<endl;cout<<"* 11.三等舱的价格:"<<q->Price[2]<<"元"<<endl;cout<<"************************"<<endl;}cout<<"您还需要其他的操作么?"<<endl;cout<<endl;cout<<"【按1】返回主菜单【按2】继续操作"<<endl;cin>>i;cout<<"************************"<<endl;cout<<endl;}}void FlightRework() //修改航班路线信息{int Customer_Number ;Flight *p,*q;char FlightNum[10];int i=0;int a=1;p=head;cout<<"请输入需要修改的航班:"<<endl;cin>>FlightNum;while (p->next&&strcmp(p->next->FlightNum,FlightNum)){p=p->next;}q=p->next;if (q==NULL){cout<<"*提示:对不起,不存在此航班,请核实您的信息!"<<endl;}else{while(a){cout<<" *******【请输入需要修改的数据】*******"<<endl;cout<<" "<<endl;cout<<" 【按1】航班号"<<endl;cout<<" "<<endl;cout<<" 【按2】飞机号"<<endl;cout<<" "<<endl;cout<<" 【按3】起始站"<<endl;cout<<" "<<endl;cout<<" 【按4】目的地"<<endl;cout<<" "<<endl;cout<<" 【按5】每周出站日期"<<endl;cout<<" "<<endl;cout<<" 【按6】成员定额"<<endl;cout<<" "<<endl;cout<<" 【按7】一等舱的价格"<<endl;cout<<" "<<endl;cout<<" 【按8】二等舱的价格"<<endl;cout<<" "<<endl;cout<<" 【按9】三等舱的价格"<<endl;cout<<" "<<endl;cout<<" 【按10】退出"<<endl;cout<<" "<<endl;cout<<" **************************************"<<endl;cin>>i;switch(i){case 1:cout<<"1.请输入航班号:"<<endl;cin>>q->FlightNum;break;case 2:cout<<"2.请输入飞机号:"<<endl;cin>>q->PlaneNum;break;case 3:cout<<"3.请输入起始站:"<<endl;cin>>q->From;break;case 4:cout<<"4.请输入目的地:"<<endl;cin>>q->Des;break;case 5:cout<<"5.请输入飞机周日:"<<endl;cin>>q->Week;break;case 6:cout<<"6.请输入乘员定额:"<<endl;Customer_Number=q->Ration-q->FreeTicket;cin>>q->Ration;q->FreeTicket=q->Ration-Customer_Number;break;case 7:cout<<"7.请输入一等舱的价格:"<<endl;cin>>q->Price[0];break;case 8:cout<<"8.请输入二等舱的价格:"<<endl;cin>>q->Price[1];break;case 9:cout<<"9.请输入三等舱的价格:"<<endl;cin>>q->Price[2];break;case 10:a=0;break;default:cout<<"*提示:对不起,请选择正确的操作!"<<endl;cout<<endl;cout<<endl;break;}}}}void FlightBuyticket() //订票{int Ticket_Amount;void Buyticket(PFlight ,int );void Buyreplace(PFlight ,int ,int );Flight *p,*q;char Des[10];int i=2;while (i!=1){cout<<"请输入目的地:"<<endl;cin>>Des;p=head;while (p->next&&strcmp(p->next->Des,Des)){p=p->next;}q=p->next;if (q==NULL){cout<<"*提示:对不起,不存在此航班,请核实您的信息!"<<endl;}else{while(i!=1){cout<<"请输入需要购买的票数:"<<endl;cin>>Ticket_Amount;while(Ticket_Amount==0 && Ticket_Amount<0){cout<<"*提示:对不起,请输入正确的票数!"<<endl;cout<<endl;cout<<"请输入需要够买的票数:"<<endl;cin>>Ticket_Amount;}if (Ticket_Amount<=q->FreeTicket){Buyticket(q,Ticket_Amount);}else{int n;cout<<"*提示:抱歉!剩余票数小于定票数,是否需要列入候补名单?(【按1】是【按2】否)"<<endl;cin>>n;Buyreplace(q,Ticket_Amount,n);}cout<<endl;cout<<"【按1】返回主菜单【按2】继续"<<endl;cin>>i;}}}}void FlightCancelticket() //退票{void Buyticket(PFlight ,int );Flight *p,*q;Customer *h,*j;char FlightNum[6];char Customer_Name[10];int Replace1_Amount; //候补第一个人的定票数int i;cout<<"**********************************"<<endl;while (i!=1){cout<<"请输入需要退定的航班号:"<<endl;cin>>FlightNum;p=head;while (p->next&&strcmp(p->next->FlightNum,FlightNum)){p=p->next;}q=p->next;if (q==NULL){cout<<"*提示:对不起,不存在此航班,请核实您的信息!"<<endl;}else{while (i!=2){cout<<"请输入所查姓名:"<<endl;cin>>Customer_Name;h=q->CustName;while (h->next&&strcmp(h->next->Name,Customer_Name)){h=h->next;}j=h->next;if(j==NULL){cout<<"*提示:对不起,查无此人,请核实您的信息!"<<endl;cout<<endl;}else{if(j->next==NULL){ //当删除最后一个结点Cusrear=h;}h->next=h->next->next;q->FreeTicket+=j->Amount;delete j;cout<<"*提示:退票成功!"<<endl;if(q->ReplName->next!=NULL){Replace1_Amount=q->ReplName->next->Amount;if (Replace1_Amount<=q->FreeTicket){Replace *rep;rep=q->ReplName->next;Customer *Cus2;Cus2=new Customer;Cus2->SeatNum=q->Ration-q->FreeTicket+1;strcpy(Cus2->FlightNum, q->FlightNum );strcpy(Cus2->Name, rep->Name );Cus2->Amount=rep->Amount;Cus2->Level=rep->Level;cout<<"*提示:"<<endl;cout<<endl;cout<<"候补乘客:"<<rep->Name<<"已经成功买票!"<<endl;cout<<endl;cout<<"航班号:"<<Cus2->FlightNum<<endl;cout<<"舱位等级为:"<<rep->Level<<"(1一等舱,2二等舱,3三等舱)"<<endl;cout<<"座位号为:"<<endl;for(int i=1;i<=(rep->Amount);i++){cout<<"No."<<Cus2->SeatNum++<<" ";}cout<<endl;if (q->CustName->next==NULL){Cusrear=q->CustName;Cusrear->next=Cus2;Cusrear=Cus2;Cusrear->next=NULL;}else{Cusrear->next=Cus2;Cusrear=Cus2;Cusrear->next=NULL;}q->FreeTicket-=rep->Amount;q->ReplName->next=q->ReplName->next->next;q->ReplacePas--;delete rep;}}}break;}}cout<<"【按1】返回主菜单,或按任意键返回【继续退票操作】!"<<endl;cout<<endl;cin>>i;}}void Flightclean()//清空{head->next=rear->next;cout<<"*提示:系统已经清空!"<<endl;cout<<endl;}void Buyticket(PFlight q,int Ticket_Amount) //买票{int n=Ticket_Amount;Customer *Cus2;Cus2=new Customer;Cus2->SeatNum=q->Ration-q->FreeTicket+1;strcpy(Cus2->FlightNum, q->FlightNum );Cus2->Amount=Ticket_Amount;cout<<"1.请输入姓名:"<<endl;cin>>Cus2->Name;cout<<"2.请输入购买票的类型:"<<endl;cout<<"【按1】一等舱,【按2】二等舱,【按3】三等舱"<<endl;cin>>Cus2->Level;cout<<"*提示:订票成功!"<<endl;cout<<endl;cout<<"舱位等级:"<<" "<<Cus2->Level<<endl;cout<<"座位号为:"<<endl;for(int i=1;i<=Ticket_Amount;i++){cout<<"No."<<Cus2->SeatNum++<<" ";}cout<<endl;if (q->CustName->next==NULL){Cusrear=q->CustName;Cusrear->next=Cus2;Cusrear=Cus2;Cusrear->next=NULL;}else{Cusrear->next=Cus2;Cusrear=Cus2;Cusrear->next=NULL;}q->FreeTicket-=Ticket_Amount;}void Buyreplace(PFlight q,int Ticket_Amount,int n) //进入候补队列{Replace *Rep2;Rep2=new Replace;if(n==1){q->ReplacePas+=Ticket_Amount;strcpy(Rep2->FlightNum,q->FlightNum);Rep2->Amount=Ticket_Amount;cout<<"1.请输入姓名:"<<endl;cin>>Rep2->Name;cout<<"2.请输入购买票的类型:"<<endl;cout<<"【按1】一等舱,【按2】二等舱,【按3】三等舱"<<endl;cin>>Rep2->Level;if(q->ReplName->next==NULL){Reprear=q->ReplName;Reprear->next=Rep2;Reprear=Rep2;Reprear->next=NULL;}else{Reprear->next=Rep2;Reprear=Rep2;Reprear->next=NULL;}}}void Display()//显示订票信息{cout<<"*提示:抱歉,该项目还在开发!"<<endl;cout<<endl;int i;cout<<"【按1】返回至主菜单"<<endl;cin>>i;while(i=1){break;}/*Customer *h,*j;char Customer_Name[10];int i;while (i!=2){cout<<"请输入所查姓名:"<<endl;cin>>Customer_Name;h=q->CustName;while (h->next&&strcmp(h->next->Name,Customer_Name)){h=h->next;}j=h->next;if(j==NULL){cout<<"*提示:对不起,查无此人,请核实您的信息!"<<endl;cout<<endl;}else{cout<<}*///Customer *p;//cout<<"已买票的乘客有:"<<endl;//cout<<endl;//cout<<":"<<p->Name<<"航班号:"<<p->FlightNum<<"订票数:"<<p->Amount<<endl;//cout<<"舱位等级:"<<p->Level<<"座位号"<<p->SeatNum;//Flight *q;//char FlightNum[10];//cout<<"以下是您所查的车次信息:"<<endl;//cout<<"************************"<<endl;//cout<<"* :"<<q->Name<<endl;//cout<<"* 航班号:"<<q->FlightNum<<endl;//cout<<"* 飞机号:"<<q->PlaneNum<<endl;//cout<<"* 起点站:"<<q->From<<endl;//cout<<"* 目的地:"<<q->Des<<endl;//cout<<"* 飞机周日:"<<q->Week<<endl;//cout<<"* 舱位等级:"<<q->Level<<endl;}******************************************************************************************************#include "AirLineSystem.h"#include<iostream.h>void main() //主程序{Cusrear=new Customer;Reprear=new Replace;head=rear=new Flight;head->next=NULL;MainMenu();}。