航空訂票系統(tǒng)代碼_第1頁
航空訂票系統(tǒng)代碼_第2頁
航空訂票系統(tǒng)代碼_第3頁
航空訂票系統(tǒng)代碼_第4頁
航空訂票系統(tǒng)代碼_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、.#include #include void FlightInsert(); /增加路線void FlightDelete();/刪除路線void FlightLookup();/航班查詢void FlightRework();/航班路線修改void FlightBuyticket();/買票void FlightCancelticket();/取消訂票void Flightclean();/清空void MainMenu();/主函數(shù)void Display();/顯示訂票信息typedef struct Customer /已定票乘客信息char Name10; /姓名int Amoun

2、t; /定票數(shù)int Level; /艙位等級(jí)int SeatNum; /座位號(hào)char FlightNum10; /所定航班號(hào)struct Customer *next;Customer;typedef struct Replace /侯補(bǔ)乘客信息char Name10; /姓名eint Amount; /定票數(shù)int Level; /艙位等級(jí)char FlightNum10; /所定航班號(hào)struct Replace *next; Replace; typedef struct Flight /航班路線信息char From10; /起點(diǎn)站名char Des10; /終點(diǎn)站名char Fl

3、ightNum10; /航班號(hào)char PlaneNum10; /航班char Week20; /飛機(jī)周日int Ration; /乘員定額int FreeTicket; /剩余票數(shù)float Price3; /票價(jià)int ReplacePas; /候補(bǔ)乘客數(shù)Replace *ReplName; /該航班的候補(bǔ)乘客名單 Customer *CustName; /該航班的已定票乘客名單struct Flight *next; /指示下一航班路線結(jié)點(diǎn)Flight,*PFlight;int Ration=0; /乘客總數(shù)Flight *head; /建立航班路線頭結(jié)點(diǎn)Flight *rear; /建

4、立航班路尾結(jié)點(diǎn) Customer *Cusrear;Replace *Reprear;void MainMenu()int i=0;while (i!=8)coutendl;cout *【歡迎使用航空訂票系統(tǒng)】*endl;cout endl;cout *【按1】增加航班路線 *endl; cout endl;cout *【按2】查詢航班路線 *endl;cout endl;cout *【按3】修改航班路線 *endl;cout endl;cout *【按4】預(yù)訂飛機(jī)票 *endl; cout endl; cout *【按5】退訂飛機(jī)票 *endl; cout endl; cout *【按6】清

5、空系統(tǒng) *endl; cout endl;cout *【按7】已訂票名單 *endl; cout endl; cout *【按8】 退出系統(tǒng) *endl; cout endl;cout *提示:當(dāng)前為主菜單i;switch(i)case 1:FlightInsert();break; /增加航班路線case 2:FlightLookup();break; /查詢航班路線 case 3:FlightRework();break; /修改航班路線case 4:FlightBuyticket();break; /預(yù)訂飛機(jī)票case 5:FlightCancelticket();break; /退訂飛

6、機(jī)票case 6:Flightclean();break; /清空系統(tǒng)case 7:Display();break; case 8:;break; default:cout*提示:抱歉,請選擇正確的操作!endl;coutendl;coutendl;break;void FlightInsert() /航班錄入/*int i=2;while(i!=1)*/Flight *p;p=new Flight;cout*正在設(shè)定新的路線*endl;coutendl;cout1.請?jiān)O(shè)定起點(diǎn)站名:p-From;cout2.請?jiān)O(shè)定終點(diǎn)站名:p-Des;cout3.請?jiān)O(shè)定航班號(hào):p-FlightNum;cout

7、4.請?jiān)O(shè)定飛機(jī)號(hào):p-PlaneNum;cout5.請?jiān)O(shè)定飛行周日:p-Week;cout6.請?jiān)O(shè)定乘員定額:p-Ration;p-FreeTicket=p-Ration;cout7.請?jiān)O(shè)定一等艙的價(jià)格:p-Price0;cout8.請?jiān)O(shè)定二等艙的價(jià)格:p-Price1;cout9.請?jiān)O(shè)定三等艙的價(jià)格: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;c

8、out設(shè)置成功!endl;cout*endl;coutendl;/*cout【按1】返回主菜單 【按2】繼續(xù)i;*/void FlightLookup() /查詢航班號(hào)Flight *p,*q;char FlightNum10;p=head;int i=0;while (i!=1)cout請輸入需要查詢的航班號(hào):FlightNum;while (p-next & strcmp(p-next-FlightNum,FlightNum)p=p-next;q=p-next;if (q=NULL)cout*提示:對不起,不存在此航班號(hào),請核實(shí)您的信息!endl;elsecout以下是您所查的車次信息:e

9、ndl;cout*endl;cout* 1.航班號(hào): FlightNumendl;cout* 2.飛機(jī)號(hào): PlaneNumendl;cout* 3.起點(diǎn)站: Fromendl;cout* 4.目的地: Desendl;cout* 5.飛機(jī)周日: Weekendl;cout* 6.成員定額: Rationendl;cout* 7.剩余票數(shù): FreeTicket張endl;cout* 8.候補(bǔ)乘客數(shù): ReplacePas人endl;cout* 9.一等艙的價(jià)格: Price0元endl;cout* 10.二等艙的價(jià)格: Price1元endl;cout* 11.三等艙的價(jià)格: Price2元

10、endl;cout*endl;cout您還需要其他的操作么?endl;coutendl;cout【按1】返回主菜單 【按2】繼續(xù)操作i;cout*endl;coutendl;void FlightRework() /修改航班路線信息int Customer_Number ;Flight *p,*q;char FlightNum10;int i=0;int a=1;p=head;cout請輸入需要修改的航班:FlightNum;while (p-next&strcmp(p-next-FlightNum,FlightNum)p=p-next;q=p-next;if (q=NULL)cout*提示:

11、對不起,不存在此航班,請核實(shí)您的信息!endl;elsewhile(a)cout *【請輸入需要修改的數(shù)據(jù)】*endl;cout endl;cout 【按1】航班號(hào) endl;cout endl;cout 【按2】飛機(jī)號(hào) 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】一等艙的價(jià)格 endl;cout endl;cout 【按8】二等艙的價(jià)格 endl;cout

12、endl; cout 【按9】三等艙的價(jià)格 endl;cout endl;cout 【按10】退出 endl;cout endl;cout *i;switch(i)case 1:cout1.請輸入航班號(hào):q-FlightNum;break;case 2:cout2.請輸入飛機(jī)號(hào):q-PlaneNum;break;case 3:cout3.請輸入起始站:q-From;break;case 4:cout4.請輸入目的地:q-Des;break;case 5:cout5.請輸入飛機(jī)周日:q-Week;break;case 6:cout6.請輸入乘員定額:Ration-q-FreeTicket; ci

13、nq-Ration;q-FreeTicket=q-Ration-Customer_Number;break;case 7:cout7.請輸入一等艙的價(jià)格:q-Price0;break;case 8:cout8.請輸入二等艙的價(jià)格:q-Price1;break; case 9:cout9.請輸入三等艙的價(jià)格:q-Price2;break;case 10:a=0;break; default:cout*提示:對不起,請選擇正確的操作!endl;coutendl;coutendl;break;void FlightBuyticket() /訂票int Ticket_Amount;void Buyti

14、cket(PFlight ,int );void Buyreplace(PFlight ,int ,int );Flight *p,*q;char Des10;int i=2;while (i!=1)cout請輸入目的地:Des; p=head;while (p-next&strcmp(p-next-Des,Des)p=p-next;q=p-next;if (q=NULL)cout*提示:對不起,不存在此航班,請核實(shí)您的信息!endl;elsewhile(i!=1)cout請輸入需要購買的票數(shù):Ticket_Amount;while(Ticket_Amount=0 & Ticket_Amoun

15、t0)cout*提示:對不起,請輸入正確的票數(shù)!endl;coutendl;cout請輸入需要夠買的票數(shù):Ticket_Amount;if (Ticket_AmountFreeTicket)Buyticket(q,Ticket_Amount);elseint n;cout*提示:抱歉!剩余票數(shù)小于定票數(shù),是否需要列入候補(bǔ)名單?(【按1】是 【按2】否)n;Buyreplace(q,Ticket_Amount,n);coutendl;cout【按1】返回主菜單 【按2】繼續(xù)i; void FlightCancelticket() /退票 void Buyticket(PFlight ,int )

16、;Flight *p,*q;Customer *h,*j;char FlightNum6;char Customer_Name10;int Replace1_Amount; /候補(bǔ)第一個(gè)人的定票數(shù)int i;cout*endl;while (i!=1)cout請輸入需要退定的航班號(hào):FlightNum;p=head;while (p-next&strcmp(p-next-FlightNum,FlightNum)p=p-next;q=p-next;if (q=NULL)cout*提示:對不起,不存在此航班,請核實(shí)您的信息!endl;elsewhile (i!=2)cout請輸入所查姓名:Cust

17、omer_Name;h=q-CustName;while (h-next&strcmp(h-next-Name,Customer_Name)h=h-next;j=h-next;if(j=NULL)cout*提示:對不起,查無此人,請核實(shí)您的信息!endl;coutnext=NULL) /當(dāng)刪除最后一個(gè)結(jié)點(diǎn)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

18、_AmountFreeTicket)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;coutendl;cout候補(bǔ)乘客:Name已經(jīng)成功買票! endl;coutendl;cout航班號(hào):Flig

19、htNumendl;cout艙位等級(jí)為:Level(1一等艙,2二等艙,3三等艙)endl;cout座位號(hào)為:endl;for(int i=1;iAmount);i+)coutNo.SeatNum+ ;coutCustName-next=NULL)Cusrear=q-CustName;Cusrear-next=Cus2;Cusrear=Cus2;Cusrear-next=NULL;elseCusrear-next=Cus2;Cusrear=Cus2;Cusrear-next=NULL;q-FreeTicket-=rep-Amount;q-ReplName-next=q-ReplName-nex

20、t-next;q-ReplacePas-;delete rep;break;cout【按1】返回主菜單,或按任意鍵返回【繼續(xù)退票操作】!endl;couti;void Flightclean()/清空head-next=rear-next;cout*提示:系統(tǒng)已經(jīng)清空!endl;coutSeatNum=q-Ration-q-FreeTicket+1;strcpy(Cus2-FlightNum, q-FlightNum );Cus2-Amount=Ticket_Amount;cout1.請輸入姓名:Cus2-Name;cout2.請輸入購買票的類型:endl;cout【按1】一等艙,【按2】二等

21、艙,【按3】三等艙Cus2-Level;cout*提示:訂票成功!endl;coutendl;cout艙位等級(jí): Levelendl;cout座位號(hào)為:endl;for(int i=1;i=Ticket_Amount;i+)coutNo.SeatNum+ ;coutCustName-next=NULL)Cusrear=q-CustName;Cusrear-next=Cus2;Cusrear=Cus2;Cusrear-next=NULL; elseCusrear-next=Cus2;Cusrear=Cus2;Cusrear-next=NULL; q-FreeTicket-=Ticket_Amou

22、nt;void Buyreplace(PFlight q,int Ticket_Amount,int n) /進(jìn)入候補(bǔ)隊(duì)列Replace *Rep2;Rep2=new Replace;if(n=1)q-ReplacePas+=Ticket_Amount;strcpy(Rep2-FlightNum,q-FlightNum);Rep2-Amount=Ticket_Amount;cout1.請輸入姓名:Rep2-Name;cout2.請輸入購買票的類型:endl;cout【按1】一等艙,【按2】二等艙,【按3】三等艙Rep2-Level;if(q-ReplName-next=NULL)Reprear=q-ReplName;Reprear-next=Rep2;Reprear=Rep2; Reprear-next=NULL;elseReprear-next=Rep2; Reprear=Rep2;Reprear-next=NULL;void Display()/顯示訂票信息cout*

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論