您的当前位置:首页正文

航空订票系统代码

2022-06-30 来源:九壹网
include include

void FlightInsert; //增加路线 void FlightDelete;//删除路线 void FlightLookup;//航班查询 void FlightRework;//航班路线修改 void FlightBuyticket;//买票

void FlightCancelticket;//取消订票 void Flightclean;//清空 void MainMenu;//主函数 void Display;//显示订票信息

typedef struct Customer //已定票乘客信息 {

char Name10; //姓名 int Amount; //定票数 int Level; //舱位等级 int SeatNum; //座位号

char FlightNum10; //所定航班号 struct Customer next;

}Customer;

typedef struct Replace //侯补乘客信息 {

char Name10; //姓名e int Amount; //定票数 int Level; //舱位等级

char FlightNum10; //所定航班号 struct Replace next;

}Replace;

typedef struct Flight //航班路线信息 {

char From10; //起点站名 char Des10; //终点站名 char FlightNum10; //航班号 char PlaneNum10; //航班 char Week20; //飞机周日 int Ration; //乘员定额 int FreeTicket; //剩余票数 float Price3; //票价

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<cout<<\"

\"<cout<<\" cout<<\" \"<cout<<\"

\"<cout<<\"

\"<欢迎使用航空订票系统\"<按1增加航班路线 \"<cout<<\" 按4预订飞机票 \"<cout<<\" \"<cout<<\" 按5退订飞机票 \"<cout<<\" \"<cout<<\" 按6清空系统 \"<cout<<\" 按7已订票名单 \"<cout<<\" 按8 退出系统 \"<cout<<\" 前为主菜单\"<>i; switchi { 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<<\"提示:抱歉;请选择正确的操作\"<}

}

}

cout<void FlightInsert //航班录入 {

/int i=2; whilei=1 {/

Flight p; p=new Flight;

cout<<\"正在设定新的路线\"<cout<<\"1.请设定起点站名:\"<>p->From;

cout<<\"2.请设定终点站名:\"<>p->Des;

cout<<\"3.请设定航班号:\"<>p->FlightNum;

cout<<\"4.请设定飞机号:\"<cin>>p->PlaneNum;

cout<<\"5.请设定飞行周日:\"<>p->Week;

cout<<\"6.请设定乘员定额:\"<>p->Ration;

p->FreeTicket=p->Ration;

cout<<\"7.请设定一等舱的价格:\"<>p->Price0;

cout<<\"8.请设定二等舱的价格:\"<>p->Price1;

cout<<\"9.请设定三等舱的价格:\"<>p->Price2;

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<<\"设置成功\"<}

}/

cout</cout<<\"按1返回主菜单 按2继续\"<>i;

void FlightLookup //查询航班号 {

Flight p;q; char FlightNum10; p=head; int i=0; while i=1 {

cout<<\"请输入需要查询的航班号:\"<>FlightNum;

while p->next && strcmpp->next->FlightNum;FlightNum { }

q=p->next; if q==NULL {

p=p->next;

cout<<\"提示:对不起;不存在此航班号;请核实您的信息

\"<\"<\"<\"<cout<<\"以下是您所查的车次信息:\"<cout<<\" 1.航班号: \"<FlightNum<PlaneNum<From<Des<Week<Ration<cout<<\" 7.剩余票数: \"<FreeTicket<<\"张\"<ReplacePas<<\"人

cout<<\" 9.一等舱的价格: \"<Price0<<\"元\"<Price1<<\"元

cout<<\" 11.三等舱的价格: \"<Price2<<\"元

cout<<\"\"<}

}

}

cout<<\"您还需要其他的操作么 \"<cout<<\"按1返回主菜单 按2继续操作\"<>i;

cout<<\"\"<void FlightRework //修改航班路线信息 {

int Customer_Number ; Flight p;q; char FlightNum10; int i=0; int a=1; p=head;

cout<<\"请输入需要修改的航班:\"<>FlightNum;

while p->next&&strcmpp->next->FlightNum;FlightNum {

p=p->next;

}

q=p->next; if q==NULL { } else {

whilea {

cout<<\" 请输入需要修改的数据\"<cout<<\" cout<<\"提示:对不起;不存在此航班;请核实您的信息\"<\"<cout<<\" 按

1

航班号

\"<cout<<\"

\"<cout<<\" 按

2

飞机号

\"<cout<<\"

\"<cout<<\" 按

3

起始站

\"<cout<<\"

\"<cout<<\" 按

4

目的地

\"<\"<\"<\"<\"<\"<\"<\"<\"<cout<<\"

cout<<\" cout<<\"

cout<<\" cout<<\"

cout<<\" cout<<\"

cout<<\" cout<<\"

按5每周出站日期 按

6

成员定额按7一等舱的价格按8二等舱的价格

\"<cout<<\" 按9三等舱的价格 \"<cout<<\"

\"<\"<\"<cin>>q->PlaneNum;break;

cin>>q->From;break;

cin>>q->Des;break;

cout<<\" 按

cout<<\"

cout<<\" \"<>i; switchi {

case 1:cout<<\"1.请输入航班号:\"<cin>>q->FlightNum;break;

case 2:cout<<\"2.请输入飞机号:\"<case 3:cout<<\"3.请输入起始站:\"<case 4:cout<<\"4.请输入目的地:\"<case 5:cout<<\"5.请输入飞机周日:\"<10

退出

cin>>q->Week;break; ;

case 7:cout<<\"7.请输入一等舱的价格:\"<case 6:cout<<\"6.请输入乘员定额:\"<Customer_Number=q->Ration-q->FreeTicket;

cin>>q->Ration;q->FreeTicket=q->Ration-Customer_Number;break

cin>>q->Price0;break;

case 8:cout<<\"8.请输入二等舱的价格:\"<cin>>q->Price1;break;

case 9:cout<<\"9.请输入三等舱的价格:\"<>q->Price2;break;

case 10:a=0;

break;

default:cout<<\"提示:对不起;请选择正确的操作\"<}

}

cout<void FlightBuyticket //订票 {

int Ticket_Amount;

void BuyticketPFlight ;int ; void BuyreplacePFlight ;int ;int ; Flight p;q; char Des10; int i=2; while i=1 {

cout<<\"请输入目的地:\"<>Des;

p=head;

while p->next&&strcmpp->next->Des;Des { }

q=p->next; if q==NULL { }

cout<<\"提示:对不起;不存在此航班;请核实您的信息\"<next;

else {

whilei=1 {

cout<<\"请输入需要购买的票数:\"<>Ticket_Amount;

whileTicket_Amount==0 && Ticket_Amount<0 { }

if Ticket_Amount<=q->FreeTicket { } else {

int n;

cout<<\"提示:抱歉剩余票数小于定票数;是否需要列入Buyticketq;Ticket_Amount;

cout<<\"提示:对不起;请输入正确的票数\"<cout<<\"请输入需要够买的票数:\"<>Ticket_Amount;

候补名单 按1是 按2否\"<}

}

}

}

}

cin>>n;

Buyreplaceq;Ticket_Amount;n;

cout<cout<<\"按1返回主菜单 按2继续\"<>i;

void FlightCancelticket //退票 {

void BuyticketPFlight ;int ; Flight p;q; Customer h;j; char FlightNum6; char Customer_Name10;

int Replace1_Amount; //候补第一个人的定票数 int i;

cout<<\"\"<cout<<\"请输入需要退定的航班号:\"<>FlightNum; p=head;

while p->next&&strcmpp->next->FlightNum;FlightNum { }

q=p->next; if q==NULL { } else {

while i=2 {

cout<<\"请输入所查姓名:\"<>Customer_Name; h=q->CustName;

while h->next&&strcmph->next->Name;Customer_Name {

h=h->next;

cout<<\"提示:对不起;不存在此航班;请核实您的信息\"<next;

\"<}

j=h->next; ifj==NULL {

cout<<\"提示:对不起;查无此人;请核实您的信息

cout<} else { ifj->next==NULL

{ //当删除最后一个结点 Cusrear=h; }

h->next=h->next->next; q->FreeTicket+=j->Amount; delete j;

cout<<\"提示:退票成功\"<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; strcpyCus2->FlightNum; q->FlightNum ; strcpyCus2->Name; rep->Name ; Cus2->Amount=rep->Amount; Cus2->Level=rep->Level; cout<<\"提示:\"<cout<<\"候补乘客:\"<Name<<\" 已经成功

买票 \"<cout<cout<<\"航班号:\"<FlightNum<Level<<\"1一等

舱;2二等舱;3三等舱\"<cout<<\"座位号为:\"<Amount;i++ {

cout<<\"No.\"<SeatNum++<<\" \";

}

cout<if q->CustName->next==NULL { } else { }

q->FreeTicket-=rep->Amount;

Cusrear->next=Cus2; Cusrear=Cus2; Cusrear->next=NULL; Cusrear=q->CustName; Cusrear->next=Cus2; Cusrear=Cus2; Cusrear->next=NULL;

q->ReplName->next=q->ReplName->next->next;

}

}

q->ReplacePas--; delete rep;

}

}

}

}

} break;

cout<<\"按1返回主菜单;或按任意键返回继续退票操作\"<>i;

void Flightclean//清空 { }

void BuyticketPFlight q;int Ticket_Amount //买票 {

int n=Ticket_Amount; Customer Cus2; Cus2=new Customer;

Cus2->SeatNum=q->Ration-q->FreeTicket+1; strcpyCus2->FlightNum; q->FlightNum ; head->next=rear->next;

cout<<\"提示:系统已经清空\"<Cus2->Amount=Ticket_Amount; cout<<\"1.请输入姓名:\"<>Cus2->Name;

cout<<\"2.请输入购买票的类型:\"<cout<<\"按1一等舱;按2二等舱;按3三等舱\"<>Cus2->Level;

cout<<\"提示:订票成功\"<cout<<\"舱位等级:\"<<\" \"<Level<cout<if q->CustName->next==NULL { }

Cusrear=q->CustName; Cusrear->next=Cus2; Cusrear=Cus2; Cusrear->next=NULL;

cout<<\"No.\"<SeatNum++<<\" \";

else{ }

Cusrear->next=Cus2; Cusrear=Cus2; Cusrear->next=NULL;

q->FreeTicket-=Ticket_Amount; }

void BuyreplacePFlight q;int Ticket_Amount;int n //进入候补队列 {

Replace Rep2; Rep2=new Replace; ifn==1 {

q->ReplacePas+=Ticket_Amount; strcpyRep2->FlightNum;q->FlightNum; Rep2->Amount=Ticket_Amount; cout<<\"1.请输入姓名:\"<>Rep2->Name;

cout<<\"2.请输入购买票的类型:\"<cout<<\"按1一等舱;按2二等舱;按3三等舱\"<cin>>Rep2->Level;

ifq->ReplName->next==NULL {

Reprear=q->ReplName; Reprear->next=Rep2; Reprear=Rep2;

Reprear->next=NULL;

} else{

Reprear->next=Rep2;

Reprear=Rep2; }

void Display//显示订票信息 {

cout<<\"提示:抱歉;该项目还在开发\"<cout<<\"按1返回至主菜单\"<>i; whilei=1 }

}

Reprear->next=NULL;

{ }

/Customer h;j;

char Customer_Name10; int i; while i=2

{

cout<<\"请输入所查姓名:\"<>Customer_Name; h=q->CustName;

while h->next&&strcmph->next->Name;Customer_Name { }

j=h->next; ifj==NULL {

cout<<\"提示:对不起;查无此人;请核实您的信息h=h->next;

break;

\"<}

cout<else { }/

cout<<

//Customer p;

//cout<<\"已买票的乘客有:\"<//cout<<\"姓名:\"<Name<<\"航班号:\"<FlightNum<<\"订票数:

\"<Amount<//cout<<\"舱位等级:\"<Level<<\"座位号\"<SeatNum; //Flight q;

//char FlightNum10;

//cout<<\"以下是您所查的车次信息:\"<//cout<<\" 姓名: \"<Name<//cout<<\" 航班号: \"<FlightNum<PlaneNum<From<Des<Week<Level<include \"AirLineSystem.h\" include void main //主程序 { }

Cusrear=new Customer; Reprear=new Replace; head=rear=new Flight; head->next=NULL; MainMenu;

因篇幅问题不能全部显示,请点此查看更多更全内容