数据结构航空客运订票系统
航空客运订票系统数据结构课程设计源代码

第一部分:需求分析1、系统名称:航空客运订票系统航空客运订票的业务活动包括:查询航线、客票预定和办理退票等。
要求在TC或VC环境下设计一个航空客运订票系统,以使上述业务可以借助计算机来完成。
2、要求:(1)每条航线所涉及的信息有:终点站名、航班号、飞机号、飞行日期(星期几)、乘员定额、余票量、已经订票的客户名单(包括姓名、订票量)以及等候替补的客户名单(包括姓名、所需票量)。
(2)作为模拟系统,全部数据可以只存放在内存中。
(3)通过此系统可以实现如下功能:①录入功能:可以录入航班情况②查询功能:根据客户提供的终点站名进行查询,可以输出以下信息:航班号、飞机号、星期几飞行和余票量等。
也可以根据航班号,查询飞机某个航线的情况。
③订票功能:根据客户提出的要求(姓名、终点站名、订票数量)查询该航班的余票量情况。
如尚有足够的余票,则为客户办理订票手续;若已满员或余票量少于订票数量,则需要重新询问客户要求,如需要,可登记排队候补。
④退票功能:根据客户提供的情况(姓名、日期、航班号),为客户办理退票手续,然后查询该航班是否有人排队候补,若有人排队,则为排在第一位的客户办理订票手续。
第二部分:系统设计图样一:设计说明1:添加航班:整个航班的信息保存在一个结构体flight中,采用结构体数组,每一个航班信息包含航班号、起飞时间、起飞城市、降落时间、降落城市、余票数量。
航班信息通过lulu()函数进行添加。
添加的信息保存在航班flight结构体数组中。
2:查询航班:查询板块分为两个部分,按姓名查找和按站名查找。
按姓名查找:通过所输入的姓名和已定客户的姓名相匹配,匹配成功则查找成功。
按站名查找:通过所输入的起始站名和终点站名进行匹配,匹配成功则查找成功。
3:订票功能:根据用户的姓名和航班号进行订票,如果所查找的航班号的余票满足用户需要的票数,则订票成功,该信息保存在Customer中,才用结构体数组,包含已定客户的姓名、客户ID、订的票数、起飞时间、起飞城市、降落时间、降落城市、航班号。
数据结构课程设计航空订票系统

—航空客运订票系统的设计与实现一、设计目的:设计一个航班订票系统,提高对信息管理、信息查找和排序算法的应用能力。
二、问题的描述:航空客运订票的业务包括查询航线和客票预定的信、客票预定和办理退票等,设计一个程序以使上述任务借助计算机完成。
三、数据结构的设计:;数之间的关系:函数间关系图如下:,【-函数调用图如上,各个函数模块化设计,函数之间的数据传递少均通过函数间相互调用,把函数之间联系起来,这样函数的重用率高,设计代码的效率更高,用很好的实用性,很好的兼容性。
五、界面设计:Main 函数中通过switch 语句对于所有的模块进行整合。
用户通过键盘通过提示输入相关信息。
对航班信息的航线查询,通过城市查询航班,订票业务,退票业务,查询已定客户信息。
六、程序设计:函数流程图:/menu display refund savefind函数refund函数list函数search函数increlist函数order 函数menu函数increqueue函数display函数print函数save函数main函数流程图如上问题:{1.问题1(1)问题描述:输入时字符数组输入不稳定。
(2)解决办法:在反复尝试中还没发现,后来在同学帮助下发现是一些基础问题,对于链表中数组字符的如scanf("%s",&p->name);这样是有问题的.虽然是一个会的人看似很简单的问题,但对于意念中存在看这样问题的人是很严重的。
由此要多多与同学交流,特别是编程的思想理念,很是重要。
对于个人存在的基本被错误要通过多编程序发现,并及时改正。
细节很决定成败。
2.问题2(1)问题描述:对于界面该觉很不舒服(2)解决办法:通过网络上搜索,查询,发现界面的模块设计好之后程序的界面要精练实用,让用户操作方便,可通过switch很好的实现我的想法。
3.问题3(1)问题描述:对于姓名的查找不知如何实现@(2)解决办法:通过查资料,看c课本发现一很好用的字符比较函数strcmp;通过字符比较是否等于0来实现对姓名的查找。
数据结构课程设计(航空客运订票系统)

(贵州大学计算机科学与信息学院贡献)#include <iostream.h> #include <process.h> #include <string.h> #include <conio.h> #include <stdio.h> #include <iomanip.h> #define MAX 60 #define NULL 0typedef struct Customer {char Name[8];int Amount;char Rank;int IDinfor;struct Customer *Next; }Customer;/* 乘客信息*//* 姓名*//* 定票数*//* 舱位等级*//* 个人信息*//* 指向下一乘客结点*/typedef struct Flight{char Des_Name[10]; char Flight_No[6];char Plane_No[6]; int Week_Day;int Customer_Amount; int Free_Amount;int Price[3];Customer *CustName; Customer *ReplName; struct Flight *Next;}Flight,*PFlight;/* 航线信息*//* 终点站名*//* 航班号*//* 飞机号*//* 飞行周日*//* 乘员定额*//* 剩余票数*//* 舱位等级的价格*//* 该航班的已定票乘客名单*//* 该航班的候补乘客名单*/ /* 指示下一航线结点*/int Customer_Count=0; Flight *Head;Flight *p2;Customer *Custp1[MAX];/* 所有航线的定票乘客总数*//* 航线头指针*//* 航线结点指针*/各条航线乘客结点指针Customer *Replp1[MAX]; int IsEmpty=1; int IsReplace=1; Customer *prior; int shouldsave=0; /* 各条航线候补结点指针 *//* ------------- 询问是否继续的函数 ------- */ char Continue(){char answer; while(1){printf("\n\t 您是否想继续 (Y/N)?"); scanf("%s",&answer); system("cls"); if(answer=='y'||answer=='Y') return 'y'; else if(answer=='n'||answer=='N')return 'n'; elseprintf("\n\t 输入有误,请重新输入 !");} }/* -------------- 操作出错函数 --------- */ void ErrorMess(){printf("\n\t 对不起,您的操作有误 !"); getch();}/* ------------- 系统退出函数 ---------- */ int ExitSystem(){char answer;printf("\n\t 您是否想要退出系统 (Y/N)?"); scanf("%s",&answer); if(answer=='y'||answer=='Y') return 1; else return 0;/* 是否有定票乘客 */ /* 是否有候补乘客 *//* 满足要求的定票乘客的前结点,以作删除操作/* ------------- 航线查找函数 -------- *//*Find_Line() 为重载函数*/int Find_Line(PFlight L,char *key)/* 核对航线是否唯一*/{int flag=0; /* 该标志位0 表示未找到相关信息,反之即找到,以下标志位同理*/Flight *p1;p1=L; /* 赋航线首地址*/if(p1==p2) /* 首航线不作比较*/return flag;while(p1!=p2&&p1!=NULL) /* 本航班号不纳入比较范围,否则会一直提示航线不唯一*/{ if(strcmp(p1->Flight_No,key)==0){flag=1;break;} p1=p1->Next;/* 指向下一航班结点*/}return flag;}int Find_Line(PFlight L,char *key,PFlight &p2,int &Flight_No)/* 航线查找函数*/ {int flag=0; /* 该标志位0 表示未找到相关信息,反之即找到*/Flight *p1;p1=L; /* 赋航线首结点*/ while(p1!=NULL){ if(strcmp(p1->Flight_No,key)==0)/* 不包括当前航线*/ {flag=1;p2=p1;break;}p1=p1->Next; /* 指向下一航班结点*/ if(p1!=NULL) /* 遇结束符不作统计范围*/ Flight_No++;}return flag;}/* ------------- 航班查找函数---------- */void Line_search(){Flight *p1;p1=Head;char Desname[50];// 查询终点站航班关键字if(Head==NULL){printf("\n\t 没有到达您想要的终点站的航班!");getch();return;}printf("\n\t 请输入终点站名:");scanf("%s",Desname);printf("\n\t 您所查询的航班的信息:\n");printf("\n _________________________________________________________________ \n");while(p1!=NULL){if(strcmp(p1->Des_Name,Desname)==0){printf("Des_Name Flight_No Plane_No Week_Day Cust_Num 1_PriceFree_Num 2_Price 3_Price\n");printf("\n%-9s%-10s%-9s%-9d%-9d%-9d%-8d%-8d%-8d",p1->Des_Name,p1->Flight_No,p1->Plane_No,p1->Week_Day,p1->Customer_Amount,p1->Free_Amount,p1->Price[0],p1->Price[1],p1->Price[2])J} p1=p1->Next;}printf("\n ___________________________________________________________________ \n");Continue();}/* ---------------- 航线添加函数-------- */void Line_Add(){Flight *p1; /* 建立临时航线结点*/ while(1){if(Head==NULL)/* 航线为空*/{ p1=p2=new Flight; /* 建立首个航线*/ Head=p2;}else{ p1=new Flight; /* 建立航线结点*/p2->Next=p1; /* 前一航线结点指向当前航班结点*/ p2=p1; /* 保留当前航班结点地址*/}printf("\n\t 添加新的航线!\n");printf("\n\t 请输入终点站名:");scanf("%s",&p2->Des_Name);while(1) /* 数据合法性检验*/{ printf("\n\t 请输入唯一的航班号:"); scanf("%s",&p2->Flight_No);if(Find_Line(Head,p2->Flight_No)) /* 存在航班号*/ printf("\n\t 航班号已经存在!\n");else break;}printf("\n\t 请输入飞机号:"); scanf("%s",&p2->Plane_No);while(1){printf("\n\t 请输入航班日期(请输入1—7 ):"); scanf("%d",&p2->Week_Day);if(p2->Week_Day<1||p2->Week_Day>7)printf("\n\t 输入日期有误,请重新输入!\n"); elsebreak;}printf("\n\t 请输入座位数量:"); scanf("%d",&p2->Customer_Amount);printf("\n\t 请输入头等舱的价钱:");scanf("%d",&p2->Price[0]);printf("\n\t 请输入二等舱的价钱:");scanf("%d",&p2->Price[1]);printf("\n\t 请输入三等舱的价钱 :"); scanf("%d",&p2->Price[2]);p2->Free_Amount=p2->Customer_Amount; p2->CustName=NULL; p2->ReplName=NULL; shouldsave=1; if(Continue()=='n'){p2->Next=NULL; return;} } }/* ----------- 航线是否为空函数 ------- */ int Empty_Flight(){if(Head==NULL){system("cls");printf("\n\t 对不起,航线不存在,按任意键返回 !"); getch(); return 1;}else return 0;}/* ----------- 航线查看函数 ---------- */ void Line_See(){system("cls"); Flight *p1; p1=Head;if(Empty_Flight()) /* 航班线为空 */return;printf("\n\n\t 航班信息 :\n");printf("\n ___________________________________________________________________ ______ \n");printf("Des_Name Flight_No Plane_No Week_Day Cust_Num Free_Num 1_Price 2_Price 3_Price\n"); while(p1!=NULL){printf("\n%-9s%-10s%-9s%-9d%-9d%-9d%-8d%-8d%-8d",p1->Des_Name,p1->Fl ight_No,p1->Plane_No,p1->Week_Day,/* 剩余票数与乘员定额相同 *//* 该航线定票乘客头指针为空 */ /* 初始候补名单为空 *//* 航线的下一结点为空 */p1->Customer_Amount,p1->Free_Amount,p1->Price[0],p1->Price[1],p1->Pric e[2]);p1=p1->Next;}printf("\n ___________________________________________________________________ ________ \n");printf("\n\t 按任意键返回!\n");getch();}/* ----------- 航线管理菜单-------- */void LinemanageMenu(){char c;system("cls");while(1){printf("\n\t\t 航线管理菜单:");printf("\n _______________ \n\n");printf("\t1. 添加新的航线\n");printf("\t2. 查询航线\n");printf("\t3. 查看航线\n");返回主菜单\n");printf("\t4.printf("\n ________________ \n");printf("\t 请选择您想要的服务:");scanf("%s",&c);switch(c){case '1':Line_Add();break;case '2':Line_search();break;case '3':Line_See();break;}case '4':return; }}}/* -------------- 订票办理函数 --------- */ void bookingMenu(){int Ticket_Count,IDinfor,i,flag=0;int Flight_No=0; /* 记录满足条件的航线的定票结点 */ Flight *p1; /* 记下满足条件的航线结点地址 *//* 临时性定票乘员结点 */ /* 临时性候补乘员结点 */ /* 用户输入的航班数据 *//* 候补乘客标志位 *//* 是否执行候补操作标志位 */ /* 航班线为空 */return; while(1) {printf("\n\t 现在您可以订票 !");flag=0; /* 标志位清零以重新作出判断 */ Flight_No=0; tag=0;printf("\n\t 请输入航线号 :"); scanf("%s",&answer);以下操作 */{while(1) /* 数据合法性检验 */ {printf("\n\t 请输入您想要订购的票的数量 :"); scanf("%d",&Ticket_Count); if(Ticket_Count==0){printf ("\n\t 请再次输入飞机号 :\n"); getch();Customer *p2; Customer *p3; char answer[7]; char temp; char c; int tag=0; int IsRepl=0;if(Empty_Flight()) if(Find_Line(Head,answer,p1,Flight_No)) /* 调用航线查找函数, 若存在则进行else break;}p1->CustName=Custp1[Flight_No]; }else /* 建立该航线的后续乘客结点 */{p2=new Customer; Custp1[Flight_No]->Next=p2; Custp1[Flight_No]=p2;}IsEmpty=0; /* 定票乘员不为空 */ Custp1[Flight_No]->Amount=Ticket_Count; /*订票数 */ IDinfor=p1->Customer_Amount-p1->Free_Amount+1; /* 算出 座位 号*/Custp1[Flight_No]->IDinfor=IDinfor; /* 赋座位号 */ p1->Free_Amount-=Ticket_Count; /* 减去定票数 */printf("\n\t 请输入您的姓名 :"); scanf("%s",&Custp1[Flight_No]->Name); while(1) /* 数据合法性检验 */ {printf("\n\t 请输入舱位等级 :"); scanf("%s",&Custp1[Flight_No]->Rank);if(!(Custp1[Flight_No]->Rank>='1'&&Custp1[Flight_No]->Rank<='3')){printf("\n\t 输入有误,请重新输入 !"); getch();}elsebreak;}printf("\n\t 请输入您的 ID 信息 :"); scanf("%d",&Custp1[Flight_No]->IDinfor);if(Ticket_Count<10) /* 为显示规整,作相应处理 */ printf("\n\t"); elseprintf("\n\t");printf("\n\t 恭喜您订票成功! \n"); for(i=1;i<=Ticket_Count;i++) /* 打印座位号 */{printf("\n\t 您所预定的座位号是 %d",IDinfor++); if(i%10==0) printf("\n\t");if(p1->Free_Amount>=Ticket_Count){Customer_Count++; flag=1; IsRepl=1;if(p1->CustName==NULL)*/{Custp1[Flight_No]=p2=new点*//* 定票乘客总数增 1*/ /* 表明进入了订票实际操作 */ /* 定票量满足,无需进入候补操作 *//* 首个定票乘客, 并记录相Customer; /* 建立该航线的首位乘客结}printf("\n");}/* 满足定票数*/else if(p1->Free_Amount==0){printf("\n\t 对不起,票已售完!\n");IsRepl=0;}else{printf("\n\t 对不起,当前没有多余的票!\n");IsRepl=0;}if(!IsRepl){printf("\n\t 您是否想成为候补乘客(Y/N)?");scanf("%s",&temp);if(temp=='y'||temp=='Y')/* 以下为候补操作*/{if(p1->ReplName==NULL){Replp1[Flight_No]=p3=new Customer; /* 建立该航线的首位候补乘客结点*/p1->ReplName=Replp1[Flight_No];}else{p3=new Customer;Replp1[Flight_No]->Next=p3;Replp1[Flight_No]=p3;}IsReplace=0; /* 候补乘客不为空*/tag=1; /* 已选择列入候补乘客名单*/Replp1[Flight_No]->Amount=Ticket_Count;printf("\n\t 请输入您的姓名:");scanf("%s",&Replp1[Flight_No]->Name);Replp1[Flight_No]->IDinfor=IDinfor; /* 候补乘客的座位*/Replp1[Flight_No]->Amount=Ticket_Count; /* 候补乘客的订票数*/while(1) /* 数据合法性检验*/{printf("\n\t 请输入舱位等级:"); scanf("%s",&Replp1[Flight_No]->Rank);printf("\n\t 请输入您的ID 信息:"); scanf("%d",&Replp1[Flight_No]->IDinfor);if(!(Replp1[Flight_No]->Rank>='1'&&Replp1[Flight_No]->Rank<='3')){printf("\n\t 输入有误,请重新输入.");getch();}elsebreak;}printf("\n\t 没有剩余座位!\n");/* 候补乘客无座提示*/shouldsave=1;}/* 进入候补名单*/}/* 票数满足*/}/* 航线存在*/elseprintf("\n\t 对不起,航线不存在!\n");/* 航线不存在*/ if(flag) /* 此处不作处理,则会地址溢出*/Custp1[Flight_No]->Next=NULL;/* 末位定票乘客的指针置空*/ if(tag){Replp1[Flight_No]->Next=NULL;/* 末位候补乘客的指针置空*/printf("\n\t 您已经成功排入候补订票队列中!\n");}printf("\n\t 是否退出菜单?:(y/n)");scanf("%s",&c);if(c=='y')return;}/*while*/}/* ---------------- 订票乘客信息----------- */void Display_Reserve(){system("cls");Flight *p1;Customer *p2;p1=Head;if(Empty_Flight())return;printf("\n\t 订票乘客信息");if(IsEmpty){printf("\n\t 对不起,没有订票乘客信息!\n"); getch();return;}printf("\n _______________________________________________________________ \n");printf("Name Flight_No Plane_No Tic_Amount Des_Name Rank_NoID\n");while(p1!=NULL){ if(p1->CustName!=NULL){ p2=p1->CustName; while(p2!=NULL){printf("\n%-8s%-10s%-9s%-11d%-9s%-9c%-9d",p2->Name,p1->Flight_No,p1->Plane_No,p2->Amount,p1->Des_Name,p2->Rank,p2->IDinfor);if(p1->Free_Amount>=1) printf("\n\n\t 还有多余的票!\n");elseprintf("\n\n\t 票已售完!\n"); p2=p2->Next;} } p1=p1->Next;printf("\n\n ________________________________________________________________ \n");}printf("\n\t 按任意键返回!"); getch();return;/* ---------------- 候补乘客信息----------- */void Display_Replace(){system("cls");Flight *p1;Customer *p2;p1=Head;if(Empty_Flight())return;printf("\n\t 候补乘客信息!");if(IsReplace){printf("\n\t 对不起,没有候补乘客!\n");getch();return;}printf("\n ________________________________________________________________ \n");printf("Name Flight_No Plane_No Tic_Amount Des_Name Rank_NoID\n");while(p1!=NULL){if(p1->ReplName!=NULL){p2=p1->ReplName;while(p2!=NULL){printf("\n%-8s%-10s%-9s%-11d%-9s%-9c%-9d",p2->Name,p1->Flight_No,p1->Plane_No,p2->Amount,p1->Des_Name,p2->Rank,p2->IDinfor);if( p1->Free_Amount>=1)printf("\n\t 还有多余的票!\n");elseprintf("\n\t 票已售完!\n");p2=p2->Next;}p2=p1->CustName; /* 指向该航线的乘客名单的首地址 */}p1=p1->Next;} printf("\n\n __________________________________________________________________ _________ \n");printf("\n\t 按任意键返回 !");getch();return;}/* ---------------- 退票办理函数 ----------- */printf ("\n\t 现在开始进行退票手续 ");if(IsEmpty){printf("\n\t 对不起,乘客不存在 !"); getch();return;}while(1){flag=0;tag=0;Flight_No=0;printf("\n\t 请输入航线 :");scanf("%s",&answer); if(Find_Line(Head,answer,p1,Flight_No)) {void RefundticketMenu(){int Flight_No=0,flag=0;Flight *p1; Customer *p2,*p4; Customer *p3,*p5; char answer[7],name[7]; int tag=0; */ int IDinfor;if(Empty_Flight()) return; /* 记录满足条件的航线的定票结点 /* 记下满足条件的航线结点地址/* 临时性定票乘员结点/* 临时性候补乘员结点 */*/ */ */*//* 若第二乘客满足条件,则它的首地址会发生冲突,注意此处/* 记录座位号 *//* 航班线为空*//* 航线存在 */printf("\n\t 请输入您的姓名 :"); scanf("%s",&name);if(p2==NULL) /* 该航线无定票乘客 {printf("\n\t 对不起,乘客不存在 !.");if(Continue()=='n')/* 是否继续操作 */ return;} elsewhile(p2!=NULL)/* 查找有无此乘客名 {if(strcmp(p2->Name,name)==0)/* { if(p2==p1->CustName) { prior=p1->CustName; /*IDinfor=p2->IDinfor; flag=1;break; }}else if(p2->Next!=NULL)/* 记录满足航线的的前结点地址 */{ if(strcmp(p2->Next->Name,name)==0){tag=1; /* 特别注意此处 */prior=p2; /* 记录满足定乘客的前一地址,以作删除操作 */IDinfor=p2->Next->IDinfor;flag=1;break;}}p2=p2->Next; /* 指向下一乘客结点 */ shouldsave=1;}/*while */ if(!flag)printf("\n\t 对不起,乘客不存在 !\n");}/* 存在该航线 */elseprintf("\n\t 对不起,航线不存在 !\n"); if(flag){if(prior==p1->CustName&&!tag) /* 首结点满足条件且一个乘客,则该航线定票乘客置空 */*/*/此外括号不能省略,否则功能会转变 *//* 若为首位乘客满足 */记录指针{if(prior->Next==NULL) /* 仅一乘客,头指针置空*/{ p1->Free_Amount+=prior->Amount; p1->CustName=NULL;}else{ p1->Free_Amount+=prior->Next->Amount; p1->CustName=prior->Next; /* 指向下一乘客结点*/}}else{p1->Free_Amount+=prior->Next->Amount; prior->Next=prior->Next->Next; /* 删除操作*/}Customer_Count--;if(Customer_Count==0)IsEmpty=1;shouldsave=1;}if(flag)/* 存在退票操作*/{p3=p1->ReplName;while(p3!=NULL){if(p3->Amount<=p1->Free_Amount)/* 候补乘客的定票数小于或等于剩余票数*/{printf("\n\t 候补乘客已经存在!\n"); p4=Custp1[Flight_No]->Next=newCustomer; p4->Next=NULL;IsEmpty=0; if(p1->CustName==NULL) p1->CustName=p4;strcpy(p4->Name,p3->Name); p4->Rank=p3->Rank; p4->Amount=p3->Amount;p4->IDinfor=IDinfor; p1->Free_Amount-=p3->Amount; /* 减去相应的票数*/Customer_Count++;if(p3->Next==NULL) /* 无候补乘客*/IsReplace=1;if(p1->ReplName==p3){if(p1->ReplName->Next==NULL) p1->ReplName=NULL;/* 删除*/ elsep1->ReplName=p3->Next;}elsep5->Next=p3->Next->Next;break;}if(p3->Next!=NULL)if(p3->Next->Amount<=p1->Free_Amount)p5=p3;p3=p3->Next; /* 指向下一候补乘客结点*/ shouldsave=1;}printf("\n\t 退票成功!");getch();return;}/* 存在此乘客*/shouldsave=1;if(Continue()=='n')return;}/*while*/}/* -------------- 乘客管理子菜单函数---------- */void CustomermagMenu(){char c;system("cls");while(1){printf("\n\t\t 乘客管理菜单:\n");printf("\n ____________________________________________________________________ _______ \n\n");printf("\t1. 乘客信息\n");printf("\t2. 候补乘客信息\n");printf("\t3. 返回主菜单 \n");printf("\n ____________________________________________________________________ _______ \n");printf("\t 请选择您想要的服务 :"); scanf("%s",&c);switch(c){case '1':Display_Reserve();break;case '2':Display_Replace();break;case '3':return; default:ErrorMess();}}}/* ------ 下面为主程序画面函数 ---- */void main(){system("color 1f"); // 屏幕颜色设定 system("mode con: cols=78 lines=35");Flight *p1;p1=Head;char c;do{system("cls");printf("\n\t\t 航空客运订票系统主菜单 \n");*************************\n");printf(" 请选择您想要的服务 :"); scanf("%s",&c);switch(c){case '1':LinemanageMenu();break; case'2':bookingMenu();break; case '3':RefundticketMenu();break;printf("\t 1. 航 线 管 理 菜 单 \n");printf("\t 2. 订 票 办 理 菜 单 \n");printf("\t 3. 退 票 办 理 菜 单 \n");printf("\t 4. 乘 客 管 理 菜 单 \n");printf("\t 5. 退 出 系 统\ n");printf("\n*************************谢 谢 使 用 航空客运订票系统!printf("\n******************************************************************************\n");/* 航线管理 *//* 订票办理 *//* 退票办理 */case '4':CustomermagMenu();break;/* 乘客管理*/ case '5':exit(0);default:break;}}while(c!='5');}。
航空客运订票系统课程设计(数据结构)解剖

XXXXXXXXX计算机技术系项目名称:航空客运订票系统学生姓名: XX学号:班级: 10801 指导教师:年月日目录1.系统需求分析 (3)1.1问题分析 (3)1.2任务意义 (3)2. 数据结构设计及用法说明 (4)3. 详细设计和编码 (5)3.1.主菜单 (5)3.2.录入航空信息 (5)3.3输出航空信息 (6)3.4订票 (7)3.5退票 (7)4. 实验结果 (9)4.1菜单函数的功能测试 (9)4.2录入函数的功能测试 (9)4.3查询航班函数的功能测试 (11)4.4订票功能地测试 (12)致谢 (17)参考文献 (18)附录:源程序清单 (19)1.系统需求分析1.1 问题分析这次的课程设计是设计一个航空系统。
由于存储的数量较大且不固定,因此选择用链表来保存基本信息:终点站名、航班号、飞机号、飞行时间、乘员定额、余票量、已经订票的客户名单(包括姓名、订票量)、等候替补的客户名单(包括姓名、所需票量)等等。
由于在航线这个主链表上,每个航班上的已经订票名单这个链表和等候替补的名单这个链表队列,所以建立一个十字交叉链表,在纵行上开辟一个链表存储所有航班的基本信息,再在各个航班节点横向展开一个链表和一个链表队列,展开的链表存储已经订票的客户名单,展开的链表队列存储等候替补的客户名单。
同时,由于预约人数无法预计,队列也应以链表作存储结构。
系统主要实现的操作和功能是:添加航线、查询航线、订票功能、退票功能。
要实现这些功能,首先要使程序能实现查找功能,在查找出到有效信息的前提之下,通过链表的赋值,更新信息和删除退票人信息,满足客户的要求。
1.2 任务意义飞机场每天要接受大量的订票退票服务,对于这些数量巨大的数据,需要一个专门的软件来进行管理和操作。
软件至少需要具备的基本功能包括:接受订票,处理退票,查询航班信息等等。
面对这些实际问题,航空客运系统的制作无疑要全面的考察一个学生的知识及能力。
数据结构课程设计(航空客运订票系统)

(贵州大学计算机科学与信息学院贡献)#include <iostream.h>#include <process.h>#include <string.h>#include <conio.h>#include <stdio.h>#include <iomanip.h>#define MAX 60#define NULL 0typedef struct Customer /*乘客信息*/{char Name[8]; /*姓名*/int Amount; /*定票数*/char Rank; /*舱位等级*/int IDinfor; /*个人信息*/struct Customer *Next; /*指向下一乘客结点*/}Customer;typedef struct Flight /*航线信息*/{char Des_Name[10]; /*终点站名*/char Flight_No[6]; /*航班号*/char Plane_No[6]; /*飞机号*/int Week_Day; /*飞行周日*/int Customer_Amount; /*乘员定额*/int Free_Amount; /*剩余票数*/int Price[3]; /*舱位等级的价格*/Customer *CustName; /*该航班的已定票乘客名单*/ Customer *ReplName; /*该航班的候补乘客名单*/ struct Flight *Next; /*指示下一航线结点*/}Flight,*PFlight;int Customer_Count=0; /*所有航线的定票乘客总数*/ Flight *Head; /*航线头指针*/Flight *p2; /*航线结点指针*/Customer *Custp1[MAX]; /*各条航线乘客结点指针*/Customer *Replp1[MAX]; /*各条航线候补结点指针*/int IsEmpty=1; /*是否有定票乘客*/int IsReplace=1; /*是否有候补乘客*/Customer *prior; /*满足要求的定票乘客的前结点,以作删除操作*/ int shouldsave=0;/*-------------询问是否继续的函数-------------*/char Continue(){char answer;while(1){printf("\n\t 您是否想继续(Y/N)?");scanf("%s",&answer);system("cls");if(answer=='y'||answer=='Y')return 'y';else if(answer=='n'||answer=='N')return 'n';elseprintf("\n\t输入有误,请重新输入!");}}/*---------------操作出错函数---------------*/void ErrorMess(){printf("\n\t对不起,您的操作有误!");getch();}/*--------------系统退出函数---------------*/int ExitSystem(){char answer;printf("\n\t 您是否想要退出系统(Y/N)?");scanf("%s",&answer);if(answer=='y'||answer=='Y')return 1;elsereturn 0;/*--------------航线查找函数-------------*//*Find_Line()为重载函数*/int Find_Line(PFlight L,char *key)/*核对航线是否唯一*/{int flag=0; /*该标志位0表示未找到相关信息,反之即找到,以下标志位同理*/ Flight *p1;p1=L; /*赋航线首地址*/if(p1==p2) /*首航线不作比较*/return flag;while(p1!=p2&&p1!=NULL) /*本航班号不纳入比较范围,否则会一直提示航线不唯一*/{if(strcmp(p1->Flight_No,key)==0){flag=1;break;}p1=p1->Next;/*指向下一航班结点*/}return flag;}int Find_Line(PFlight L,char *key,PFlight &p2,int &Flight_No)/*航线查找函数*/{int flag=0; /*该标志位0表示未找到相关信息,反之即找到*/Flight *p1;p1=L; /*赋航线首结点*/while(p1!=NULL){if(strcmp(p1->Flight_No,key)==0)/*不包括当前航线*/{flag=1;p2=p1;break;}p1=p1->Next; /*指向下一航班结点*/if(p1!=NULL) /*遇结束符不作统计范围*/Flight_No++;}return flag;}/*---------------航班查找函数---------------*/void Line_search(){Flight *p1;p1=Head;char Desname[50];//查询终点站航班关键字if(Head==NULL){printf("\n\t没有到达您想要的终点站的航班!");getch();return;}printf("\n\t请输入终点站名:");scanf("%s",Desname);printf("\n\t您所查询的航班的信息:\n");printf("\n_______________________________________________________________________ ______\n");while(p1!=NULL){if(strcmp(p1->Des_Name,Desname)==0){printf("Des_Name Flight_No Plane_No Week_Day Cust_Num Free_Num 1_Price 2_Price 3_Price\n");printf("\n%-9s%-10s%-9s%-9d%-9d%-9d%-8d%-8d%-8d",p1->Des_Name,p1->Flight_No,p1->P lane_No,p1->Week_Day,p1->Customer_Amount,p1->Free_Amount,p1->Price[0],p1->Price[1],p1->Price[2]);}p1=p1->Next;}printf("\n_______________________________________________________________________ _______\n");Continue();}/*-----------------航线添加函数-------------*/void Line_Add()Flight *p1; /*建立临时航线结点*/while(1){if(Head==NULL)/*航线为空*/{p1=p2=new Flight; /*建立首个航线*/Head=p2;}else{p1=new Flight; /*建立航线结点*/p2->Next=p1; /*前一航线结点指向当前航班结点*/p2=p1; /*保留当前航班结点地址*/}printf("\n\t添加新的航线!\n");printf("\n\t请输入终点站名:");scanf("%s",&p2->Des_Name);while(1) /*数据合法性检验*/{printf("\n\t请输入唯一的航班号:");scanf("%s",&p2->Flight_No);if(Find_Line(Head,p2->Flight_No)) /*存在航班号*/printf("\n\t航班号已经存在!\n");elsebreak;}printf("\n\t请输入飞机号:");scanf("%s",&p2->Plane_No);while(1){printf("\n\t请输入航班日期(请输入1—7):");scanf("%d",&p2->Week_Day);if(p2->Week_Day<1||p2->Week_Day>7)printf("\n\t输入日期有误,请重新输入!\n");elsebreak;}printf("\n\t请输入座位数量:");scanf("%d",&p2->Customer_Amount);printf("\n\t请输入头等舱的价钱:");scanf("%d",&p2->Price[0]);printf("\n\t请输入二等舱的价钱:");scanf("%d",&p2->Price[1]);printf("\n\t请输入三等舱的价钱:");scanf("%d",&p2->Price[2]);p2->Free_Amount=p2->Customer_Amount; /*剩余票数与乘员定额相同*/p2->CustName=NULL; /*该航线定票乘客头指针为空*/p2->ReplName=NULL; /*初始候补名单为空*/shouldsave=1;if(Continue()=='n'){p2->Next=NULL; /*航线的下一结点为空*/return;}}}/*------------航线是否为空函数-------------*/int Empty_Flight(){if(Head==NULL){system("cls");printf("\n\t对不起,航线不存在,按任意键返回!");getch();return 1;}elsereturn 0;}/*------------航线查看函数-----------------*/void Line_See(){system("cls");Flight *p1;p1=Head;if(Empty_Flight()) /*航班线为空*/return;printf("\n\n\t航班信息:\n");printf("\n_______________________________________________________________________ _____\n");printf("Des_Name Flight_No Plane_No Week_Day Cust_Num Free_Num 1_Price 2_Price3_Price\n");while(p1!=NULL){printf("\n%-9s%-10s%-9s%-9d%-9d%-9d%-8d%-8d%-8d",p1->Des_Name,p1->Flight_No,p1->P lane_No,p1->Week_Day,p1->Customer_Amount,p1->Free_Amount,p1->Price[0],p1->Price[1],p1->Price[2]);p1=p1->Next;}printf("\n_______________________________________________________________________ ______\n");printf("\n\t按任意键返回!\n");getch();}/*-------------航线管理菜单------------*/void LinemanageMenu(){char c;system("cls");while(1){printf("\n\t\t航线管理菜单:");printf("\n_______________________________________________________________________ ______\n\n");printf("\t1.添加新的航线\n");printf("\t2.查询航线\n");printf("\t3.查看航线\n");printf("\t4.返回主菜单\n");printf("\n_______________________________________________________________________ _______\n");printf("\t请选择您想要的服务:");scanf("%s",&c);switch(c){case '1':Line_Add();break;case '2':Line_search();break;case '3':Line_See();break;case '4':return;}}}/*---------------订票办理函数---------------*/void bookingMenu(){int Ticket_Count,IDinfor,i,flag=0;int Flight_No=0; /*记录满足条件的航线的定票结点*/Flight *p1; /*记下满足条件的航线结点地址*/Customer *p2; /*临时性定票乘员结点*/Customer *p3; /*临时性候补乘员结点*/char answer[7]; /*用户输入的航班数据*/char temp;char c;int tag=0; /*候补乘客标志位*/int IsRepl=0; /*是否执行候补操作标志位*/if(Empty_Flight()) /*航班线为空*/return;while(1){printf("\n\t现在您可以订票!");flag=0; /*标志位清零以重新作出判断*/Flight_No=0;tag=0;printf("\n\t请输入航线号:");scanf("%s",&answer);if(Find_Line(Head,answer,p1,Flight_No)) /*调用航线查找函数,若存在则进行以下操作*/{while(1) /*数据合法性检验*/{printf("\n\t请输入您想要订购的票的数量:");scanf("%d",&Ticket_Count);if(Ticket_Count==0){printf("\n\t请再次输入飞机号:\n");getch();}elsebreak;}if(p1->Free_Amount>=Ticket_Count){Customer_Count++; /*定票乘客总数增1*/flag=1; /*表明进入了订票实际操作*/IsRepl=1; /*定票量满足,无需进入候补操作*/if(p1->CustName==NULL) /*首个定票乘客,并记录相关属性*/ {Custp1[Flight_No]=p2=new Customer; /*建立该航线的首位乘客结点*/ p1->CustName=Custp1[Flight_No];}else /*建立该航线的后续乘客结点*/{p2=new Customer;Custp1[Flight_No]->Next=p2;Custp1[Flight_No]=p2;}IsEmpty=0; /*定票乘员不为空*/Custp1[Flight_No]->Amount=Ticket_Count; /*订票数*/IDinfor=p1->Customer_Amount-p1->Free_Amount+1; /*算出座位号*/Custp1[Flight_No]->IDinfor=IDinfor; /*赋座位号*/p1->Free_Amount-=Ticket_Count; /*减去定票数*/printf("\n\t请输入您的姓名:");scanf("%s",&Custp1[Flight_No]->Name);while(1) /*数据合法性检验*/{printf("\n\t请输入舱位等级:");scanf("%s",&Custp1[Flight_No]->Rank);if(!(Custp1[Flight_No]->Rank>='1'&&Custp1[Flight_No]->Rank<='3')){printf("\n\t输入有误,请重新输入!");getch();}elsebreak;}printf("\n\t请输入您的ID信息:");scanf("%d",&Custp1[Flight_No]->IDinfor);if(Ticket_Count<10) /*为显示规整,作相应处理*/printf("\n\t");elseprintf("\n\t");printf("\n\t恭喜您订票成功!\n");for(i=1;i<=Ticket_Count;i++) /*打印座位号*/{printf("\n\t您所预定的座位号是%d",IDinfor++);if(i%10==0)printf("\n\t");}printf("\n");}/*满足定票数*/else if(p1->Free_Amount==0){printf("\n\t对不起,票已售完!\n");IsRepl=0;}else{printf("\n\t对不起,当前没有多余的票!\n");IsRepl=0;}if(!IsRepl){printf("\n\t您是否想成为候补乘客(Y/N)?");scanf("%s",&temp);if(temp=='y'||temp=='Y')/*以下为候补操作*/{if(p1->ReplName==NULL){Replp1[Flight_No]=p3=new Customer; /*建立该航线的首位候补乘客结点*/p1->ReplName=Replp1[Flight_No];}else{p3=new Customer;Replp1[Flight_No]->Next=p3;Replp1[Flight_No]=p3;}IsReplace=0; /*候补乘客不为空*/tag=1; /*已选择列入候补乘客名单*/Replp1[Flight_No]->Amount=Ticket_Count;printf("\n\t请输入您的姓名:");scanf("%s",&Replp1[Flight_No]->Name);Replp1[Flight_No]->IDinfor=IDinfor; /*候补乘客的座位*/Replp1[Flight_No]->Amount=Ticket_Count; /*候补乘客的订票数*/while(1) /*数据合法性检验*/{printf("\n\t请输入舱位等级:");scanf("%s",&Replp1[Flight_No]->Rank);printf("\n\t请输入您的ID信息:");scanf("%d",&Replp1[Flight_No]->IDinfor);if(!(Replp1[Flight_No]->Rank>='1'&&Replp1[Flight_No]->Rank<='3')){printf("\n\t输入有误,请重新输入.");getch();}elsebreak;}printf("\n\t没有剩余座位!\n");/*候补乘客无座提示*/shouldsave=1;}/*进入候补名单*/}/*票数满足*/}/*航线存在*/elseprintf("\n\t对不起,航线不存在!\n");/*航线不存在*/if(flag) /*此处不作处理,则会地址溢出*/Custp1[Flight_No]->Next=NULL;/*末位定票乘客的指针置空*/ if(tag){Replp1[Flight_No]->Next=NULL;/*末位候补乘客的指针置空*/printf("\n\t您已经成功排入候补订票队列中!\n");}printf("\n\t是否退出菜单?:(y/n)");scanf("%s",&c);if(c=='y')return;}/*while*/}/*-----------------订票乘客信息-----------------*/void Display_Reserve(){system("cls");Flight *p1;Customer *p2;p1=Head;if(Empty_Flight())return;printf("\n\t订票乘客信息");if(IsEmpty){printf("\n\t对不起,没有订票乘客信息!\n");getch();return;}printf("\n_______________________________________________________________________ ______\n");printf("Name Flight_No Plane_No Tic_Amount Des_Name Rank_No ID\n");while(p1!=NULL){if(p1->CustName!=NULL){p2=p1->CustName;while(p2!=NULL){printf("\n%-8s%-10s%-9s%-11d%-9s%-9c%-9d",p2->Name,p1->Flight_No,p1->Plane_No,p2->A mount,p1->Des_Name,p2->Rank,p2->IDinfor);if(p1->Free_Amount>=1)printf("\n\n\t还有多余的票!\n");elseprintf("\n\n\t票已售完!\n");p2=p2->Next;}}p1=p1->Next;printf("\n\n______________________________________________________________________ _______\n");}printf("\n\t按任意键返回!");getch();return;}/*-----------------候补乘客信息-----------------*/void Display_Replace(){system("cls");Flight *p1;Customer *p2;p1=Head;if(Empty_Flight())return;printf("\n\t候补乘客信息!");if(IsReplace){printf("\n\t对不起,没有候补乘客!\n");getch();return;}printf("\n_______________________________________________________________________ ______\n");printf("Name Flight_No Plane_No Tic_Amount Des_Name Rank_No ID\n");while(p1!=NULL){if(p1->ReplName!=NULL){p2=p1->ReplName;while(p2!=NULL){printf("\n%-8s%-10s%-9s%-11d%-9s%-9c%-9d",p2->Name,p1->Flight_No,p1->Plane_No,p2->A mount,p1->Des_Name,p2->Rank,p2->IDinfor);if( p1->Free_Amount>=1)printf("\n\t还有多余的票!\n");elseprintf("\n\t票已售完!\n");p2=p2->Next;}}p1=p1->Next;}printf("\n\n______________________________________________________________________ _______\n");printf("\n\t按任意键返回!");getch();return;}/*-----------------退票办理函数-----------------*/void RefundticketMenu(){int Flight_No=0,flag=0; /*记录满足条件的航线的定票结点*/Flight *p1; /*记下满足条件的航线结点地址*/Customer *p2,*p4; /*临时性定票乘员结点*/Customer *p3,*p5; /*临时性候补乘员结点*/char answer[7],name[7]; /*用户输入的航班数据*/int tag=0; /*若第二乘客满足条件,则它的首地址会发生冲突,注意此处*/ int IDinfor; /*记录座位号*/if(Empty_Flight()) /*航班线为空*/return;printf("\n\t现在开始进行退票手续");if(IsEmpty){printf("\n\t对不起,乘客不存在!");getch();return;}while(1){flag=0;tag=0;Flight_No=0;printf("\n\t请输入航线:");scanf("%s",&answer);if(Find_Line(Head,answer,p1,Flight_No)) /*航线存在*/{p2=p1->CustName; /*指向该航线的乘客名单的首地址*/printf("\n\t请输入您的姓名:");scanf("%s",&name);if(p2==NULL) /*该航线无定票乘客*/{printf("\n\t对不起,乘客不存在!.");if(Continue()=='n')/*是否继续操作*/return;}elsewhile(p2!=NULL)/*查找有无此乘客名*/{if(strcmp(p2->Name,name)==0)/*此外括号不能省略,否则功能会转变*/{if(p2==p1->CustName) /*若为首位乘客满足*/{prior=p1->CustName; /*记录指针*/IDinfor=p2->IDinfor;flag=1;break;}}else if(p2->Next!=NULL)/*记录满足航线的的前结点地址*/{if(strcmp(p2->Next->Name,name)==0){tag=1; /*特别注意此处*/prior=p2; /*记录满足定乘客的前一地址,以作删除操作*/IDinfor=p2->Next->IDinfor;flag=1;break;}}p2=p2->Next; /*指向下一乘客结点*/shouldsave=1;}/*while */if(!flag)printf("\n\t对不起,乘客不存在!\n");}/*存在该航线*/elseprintf("\n\t对不起,航线不存在!\n");if(flag){if(prior==p1->CustName&&!tag) /*首结点满足条件且一个乘客,则该航线定票乘客置空*/{if(prior->Next==NULL) /*仅一乘客,头指针置空*/{p1->Free_Amount+=prior->Amount;p1->CustName=NULL;}else{p1->Free_Amount+=prior->Next->Amount;p1->CustName=prior->Next; /*指向下一乘客结点*/}}else{p1->Free_Amount+=prior->Next->Amount;prior->Next=prior->Next->Next; /*删除操作*/}Customer_Count--;if(Customer_Count==0)IsEmpty=1;shouldsave=1;}if(flag)/*存在退票操作*/{p3=p1->ReplName;while(p3!=NULL){if(p3->Amount<=p1->Free_Amount)/*候补乘客的定票数小于或等于剩余票数*/ {printf("\n\t候补乘客已经存在!\n");p4=Custp1[Flight_No]->Next=new Customer;p4->Next=NULL;IsEmpty=0;if(p1->CustName==NULL)p1->CustName=p4;strcpy(p4->Name,p3->Name);p4->Rank=p3->Rank;p4->Amount=p3->Amount;p4->IDinfor=IDinfor;p1->Free_Amount-=p3->Amount; /*减去相应的票数*/Customer_Count++;if(p3->Next==NULL) /*无候补乘客*/IsReplace=1;if(p1->ReplName==p3){if(p1->ReplName->Next==NULL)p1->ReplName=NULL;/*删除*/elsep1->ReplName=p3->Next;}elsep5->Next=p3->Next->Next;}if(p3->Next!=NULL)if(p3->Next->Amount<=p1->Free_Amount)p5=p3;p3=p3->Next; /*指向下一候补乘客结点*/shouldsave=1;}printf("\n\t退票成功!");getch();return;}/*存在此乘客*/shouldsave=1;if(Continue()=='n')return;}/*while*/}/*---------------乘客管理子菜单函数-----------------*/void CustomermagMenu(){char c;system("cls");while(1){printf("\n\t\t乘客管理菜单:\n");printf("\n_______________________________________________________________________ ______\n\n");printf("\t1.乘客信息\n");printf("\t2.候补乘客信息\n");printf("\t3.返回主菜单\n");printf("\n_______________________________________________________________________ ______\n");printf("\t请选择您想要的服务:");scanf("%s",&c);switch(c){case '1':Display_Reserve();break;case '2':Display_Replace();break;default:ErrorMess();}}}/*-------下面为主程序画面函数----------*/void main(){system("color 1f"); //屏幕颜色设定system("mode con: cols=78 lines=35");Flight *p1;p1=Head;char c;do{system("cls");printf("\n\t\t 航空客运订票系统主菜单\n");printf("\n*********************************************************************** *******\n");printf("\t 1.航线管理菜单\n");printf("\t 2.订票办理菜单\n");printf("\t 3.退票办理菜单\n");printf("\t 4.乘客管理菜单\n");printf("\t 5.退出系统\n");printf("\n************************* 谢谢使用航空客运订票系统!*************************\n");printf("请选择您想要的服务:");scanf("%s",&c);switch(c){case '1':LinemanageMenu();break; /*航线管理*/case '2':bookingMenu();break; /*订票办理*/case '3':RefundticketMenu();break; /*退票办理*/case '4':CustomermagMenu();break; /*乘客管理*/case '5':exit(0);default:break;}}while(c!='5');}。
数据结构课程设计-航空订票系统

数据结构课程设计报告设计题目:航空客运订票系统院系年级学生学号指导教师2015年11月26日目录一、课程设计目的 3二、需求分析 3三、概要设计1.设计步骤 42.系统整体结构图 53.功能模块及调用关系说明 5四、详细设计和源代码1.实现概要设计中定义数据的存储结构 62.查询航线信息功能的算法设计73.订票功能的算法设计94.退票功能的算法设计125.录入功能的算法设计 146.总航线预览功能的程序源代码15五、调试分析1.各功能的具体实例分析162.实验过程中出现的问题及解决方法 20六、课程设计总结20七、参考资料21一、课程设计目的(1) 熟练使用 C 语言编写程序,解决实际问题;(2) 了解并掌握数据结构与算法的设计方法,具备初步的独立分析和设计能力;(3) 初步掌握软件开发过程的问题分析、系统设计、程序编码、测试等基本方法和技能;(4) 提高综合运用所学的理论知识和方法独立分析和解决问题的能力;航空订票系统:(1)熟练掌握链表存储结构及其建立过程和常用操作;(2)熟练掌握队列的建立过程和常用操作;(3)学会自己调试程序的方法并掌握一定的技巧。
二、需求分析问题描述:航空客运订票的业务活动包括:查询航线、客票预订和办理退票等。
试设计一个航空客运订票系统,以使上述业务可以借助计算机来完成。
设计任务:通过此系统可以实现如下功能:录入:可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定)查询:可以查询某个航线的情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班是否满仓);可以输入起飞抵达城市,查询飞机航班情况;根据旅客提出的终点站名输出下列信息:航班号、飞机号、星期几飞行,最近一天航班的日期和余票额;订票:(订票情况可以存在一个数据文件中,结构自己设定)根据客户提出的要求(日期、航班号、订票数额)查询该航班票额情况,若尚有余额,则为客户办理订票手续,输出座位号;若已满员或余票额少于订票额,则需要重新询问客户要求。
数据结构航空客运订票系统实验报告

一.实验目的1.掌握使用VC+吐机调试队列的基本方法;2.掌握队列的基本操作:初始化,出队列,入队列等运算在顺序和链式存储结构上的实现。
3.了解队列的抽象数据类型定义4.熟练掌握链队列的定义,熟练掌握链队列表的基本算法及时间性能二.实验内容航班订票系统航空客运订票业务包括:查询航线,客票预订,办理退票等。
设计一个航空客运订票系统。
三.实验步骤(可选)typedef struct pas{CString nam;int bok;intlev;}pas;typedef struct wai{CString nam;int ned;}wai;typedef struct lpa{ pas man;struct lpa *next;}lpa,*ppa;typedef struct qnode{//非队候队列wai ren;struct qnode* next;}qnode,*ptrq;typedef struct flyinfo{CString des;CString fli;CString air;CString day;int tol;int lef;ppa chk;ptrq pwa;int flg;}flyinfo;typedef struct{ptrq front;ptrq rear;}linkq;void initq(linkq &q){q. front=q .rear=new qnode;q. front->next=NULL;}void rudui(linkq & q,wai man) {ptrq p;p=new qnode;p->ren .nam=man .nam;p->ren .ned=man .ned;p->next=NULL;q. rear->next=p;q. rear=p;}void chudui(linkq & q,wai & man) {if(q. front==q. rear)return;ptrq p;p=q. front->next;man .nam=p->ren .nam;man .ned=p->ren .ned;q. front->next=p->next;if(p==q.rear)q. front=q. rear;delete p;}/*typedef struct {flyinfo *bas;int len;}slist;void initlist(slist & I){I. bas=(flyinfo*)malloc(sizeof(flyinfo)*10);I. len=0;}*/void initchk(ppa &lis){lis=new lpa;lis->next=NULL;}void addpas(ppa & lis,pas miz){ppa pl=new lpa;ppa p=lis;while(p!=NULL)p=p->next;pl->man=miz;p=pl;pl->next=NULL;}void dele(ppa & lis,pas miz) {ppa p,q;p=q=lis;for(;q!=NULL;){if(q->man.nam==miz. nam){p->next=q->next;delete p;break;}p=q;q=q->next;}}flyinfo fly[10];linkq q[10];//paiduippa lis[10];//订票客户链表int fg=0;int fnum=0;BOOL CMyDlg::OnlnitDialog(){CDialog::OnInitDialog();//initlist(fly);initchk(lis[0]);initq(q[0]);initchk(lis[1]);initq(q[1]);fly[1] ・des=" 上海";fly[1] .air="CV902";fly[1] ・day=" 星期二";fly[1] ・fli="XXDDD";fly[1] ・tol=300;fly[1]・l ef=5;fly[0] ・des=" 南京";fly[0] .air="CV902";fly[0] ・day=" 星期三";fly[0] ・fli="XXODD";fly[0] ・tol=300;fly[0] ・lef=5;wai p1,p2;pl .nam="jack";pl. ned=10;p2・nam="rose";p2・ned=30;rudui(q[0],p1);rudui(q[0],p2);rudui(q[1],p1);rudui(q[1],p2);pas pa1,pa2;pal ・bok=2;pa1 ・l ev=1;pa1 ・nam="leke";pa2・bok=2;pa2 ・lev=1;pa2 .nam="bake";addpas(lis[0],pa1);addpas(lis[1],pa2);〃m_des=fly[0] ・des;// Add "About ・・・" menu item to system menu.// IDM_ABOUTBOX must be in the system command range.ASSERT((IDM_ABOUTBOX & OxFFFO) == IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) {CString strAboutMenu;strAboutMenu ・LoadString(IDS_ABOUTBOX);if (!strAboutMenu ・lsEmpty()){pSysMenu->AppendMenu(MF_SEPARATOR);pSysMenu->AppendMenu(MF_STRING , IDM_ABOUTBOX, strAboutMenu);}}void CMyDlg::OnBUTTONdingpiao(){fg=0;//biaozhi dingpiaoCAboutDlg dlg;dlg .DoModal();void CMyDlg::OnBUTTONnext() {if(fnum<=0){fnum++;m_air=fly[fnum] .air;m_des=fly[fnum] .des;m_flight=fly[fnum] .fli;m_total=fly[fnum] ・tol;m_left=fly[fnum] ・lef;m_day=fly[fnum] .day;UpdateData(false);}elseMessageBox("last!");} void CMyDlg::OnBUTTONup() { if(fnum>0){fnum--; m_air=fly[fnum] .air; m_des=fly[fnum] .des; m_f light=fly[fnum] .fli;m_total=fly[fnum] .tol; m_left=fly[fnum] .lef; m_day=fly[fnum] .day; UpdateData(false); } elseMessageBox("first!");}void CAboutDlg::OnOK(){UpdateData();pas pa;pa.l ev=m_levl;pa. bok=m_number;pa. nam=m_name;if(fg==0){addpas(lis[fnum],pa); MessageBox(‘ 订票成功!"); }elseif(fg==1){dele(lis[fnum],pa); MessageBox(‘ 退票成功!");} else{wai pd;pd・nam=m_name;pd・ned=m_number;rudui(q[fnum],pd);MessageBox('登记成功!"); }CDialog::OnOK();} void CMyDlg::OnButtonout(){fg=1;CAboutDlg dlg;dlg .DoModal();}void CMyDlg::OnBUTTONwait(){fg=2;CAboutDlg dlg;dig ・DoModal();五.实验中出现的问题、解决方法和心得体会1.通过本次实验,基本上了解了链队列的存储结构及其算法的实现,了解了链队列的特点以及链队列抽象出的数据类型的定义,基本上掌握了链队列基本算法如何实现,包括如何实现建立,查找,插入,删除,合并,销毁,数据排序等操作。
数据结构航空客运订票系统

航空客运订票系统程序要求:1、问题描述航空客运订票的业务活动包括:查询航线、客票预订和办理退票等。
设计一个航空客运订票系统,以使上述业务可以借助计算机完成。
2、要求1)每条航线所涉及的信息有:终点站名、航班号、飞机号、飞行周日(星期几)、乘员定额、余票量、已订票的客户名单(包括名字、订票量、舱位等级1、2、3)以及等候替补的客户名单;2)系统实现的功能如下:通过此系统可以实现如下功能:录入:可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定)查询:可以查询某个航线的情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班是否满仓);可以输入起飞抵达城市,查询飞机航班情况;订票:(订票情况可以存在一个数据文件中,结构自己设定)可以订票,如果该航班已经无票,可以提供相关可选择航班;退票:可退票,退票后修改相关数据文件;客户资料有姓名,证件号,订票数量及航班情况,订单要有编号。
修改航班信息:当航班信息改变可以修改航班数据文件存储结构:航线的所有信息存储在一个结构体中,增加,查询,订票,退票等操作按队列的操作来实现。
详细代码:#include <>#include <>#include <>#include <>#define m 4 查看排队情况*";cout<<endl<<" * 1 . 订票*";cout<<endl<<" * 2 . 退票*";cout<<endl<<" * 3 . 查看剩余票*";cout<<endl<<" * 4 . 查看飞机信息*";cout<<endl<<" * 5 . 查看乘客信息*";cout<<endl<<" * 6 . 退出*";cout<<endl<<" ************************";cout<<endl<<"";}void makenull_piao(){FILE *fp;int i;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);}void makenull_information(){node *r;FILE *fp;int i,j,sum;sum=a[1].seat[0]+a[2].seat[0]+a[3].seat[0];fp=fopen("","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;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->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;}}}void makenull_wait(){wait *tempw;FILE *fp;tempw=new wait;int i;if((fp=fopen("","r")) ==NULL ){fp=fopen("","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("","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;}}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<<endl;}else cout<<endl<<"The "<<i<<" plane is full !"<<endl<<endl;}}void list_information(){int x;do {cout<<endl<<"显示哪架飞机的信息"; cin>>x;cout<<endl;}while(x<1 || x>=m);cout<<endl<<"第"<<x<<" 架飞机的信息如下"<<endl;if(x==1) plane_information(head1);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<<"飞机空,无预订票!"<<endl;}while(q!=NULL){cout<<endl<<"*******************"<<endl;q->date=q->plane;cout<<"日期:"<<q->date<<endl;cout<<"座位号: "<<q->seat<<endl;cout<<"姓名: "<<q->name;cout<<endl<<"ID 号: "<<q->id;q=q->next;x++;if (x % 3 ==0) 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<<"**** 超出范围!****"<<endl<<"请重新输入:";}else{cout<<endl<<"你要订的是到"<<i<<"地的飞机"<<endl;cout<<endl<<"第"<<i<<" 架飞机剩余的票:"<<endl;for(p=1;p<=n;p++)if (a[i].seat[p]==0) cout<<" "<<p;cout<<endl;break;}}while(1);cout<<endl<<"请选择座位号: ";do {cin>>j;if (j<1 || j>n) {cout<<endl<<"**** 超出范围!****"<<endl<<"请重新输入:";}else{q->date=i;cout<<endl<<"您的订票日期: "<<q->date<<endl;break;}}while(1);if (a[i].seat[j]==0) {a[i].seat[j]=1;cout<<endl;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{ cout<<endl<<"**** 对不起,该座位已被预订,您被安排到订票等候队列****"<<endl;add_wait(i,j);}}void add_wait(int x,int y){wait *tempw;tempw=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=wait_end;wait_end=wait_end->next;cout<<endl<<"**** 正在排队等候****"<<endl;wait_head->count++;write_to_file();}void show_wait(){wait *tempw;tempw=wait_head->next;if (tempw==NULL) cout<<endl<<"排队中没有人!"<<endl;while(tempw!=NULL){cout<<tempw->name<<" - ";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>>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; }void search_delete(int x){node *p,*q,*r;wait *tempw,*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<<"请输入个人信息"<<endl;cout<<"*************"<<endl;cout<<endl<<"姓名: ";cin>>p->name;do{q=q->next;if ( (q!=NULL) &&(comp(q,p)) ){cout<<endl;q->date=q->plane;cout<<"Located!"<<endl;cout<<"****************";cout<<endl<<"姓名: "<<q->name;cout<<endl<<"ID号: "<<q->id;cout<<endl<<"座位号: "<<q->seat;cout<<endl<<"班机号: "<<q->plane;cout<<endl<<"日期: "<<q->date<<endl;if (x==1) {cout<<"删除该纪录[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);cout<<endl<<"等候的人中有可以订票的了:"<<endl;cout<<endl<<"姓名: "<<tempw->name;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)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;else tempw->next->pre=tempw2;delete(tempw);wait_head->count--;write_to_file();cout<<endl<<"等候的"<<tempw3->name<<"已经成功订票,已经由电话"<<tempw3->phone<<"通知了"<<endl;break;}}}}continue;}else{if (q==NULL){step++;if(step==2) q=head2;if(step==3) q=head3;if(step==4) {cout<<endl<<"**** 信息检索完毕****";break;}}}}while(1);}bool comp(node *x,node *y){node *p,*q;int i,j,k;p=x;q=y;i=j=0;do{while ( (p->name[i] != q->name[j]) && (p->name[i] != '\0') ) 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;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("","w");for (i=1;i<=m-1;i++){fwrite(&a[i],sizeof(piao),1,fp);}fclose(fp);fp=fopen("","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++){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("","w");for(j=0;j<=wait_head->count;j++){if(tempw==NULL)break;fwrite(tempw,sizeof(wait),1,fp);tempw=tempw->next;}fclose(fp); }。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
航空客运订票系统程序要求:1、问题描述航空客运订票的业务活动包括:查询航线、客票预订和办理退票等。
设计一个航空客运订票系统,以使上述业务可以借助计算机完成。
2、要求1)每条航线所涉及的信息有:终点站名、航班号、飞机号、飞行周日(星期几)、乘员定额、余票量、已订票的客户名单(包括名字、订票量、舱位等级1、2、3)以及等候替补的客户名单;2)系统实现的功能如下:通过此系统可以实现如下功能:录入:可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定)查询:可以查询某个航线的情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班是否满仓);可以输入起飞抵达城市,查询飞机航班情况;订票:(订票情况可以存在一个数据文件中,结构自己设定)可以订票,如果该航班已经无票,可以提供相关可选择航班;退票:可退票,退票后修改相关数据文件;客户资料有姓名,证件号,订票数量及航班情况,订单要有编号。
修改航班信息:当航班信息改变可以修改航班数据文件存储结构:航线的所有信息存储在一个结构体中,增加,查询,订票,退票等操作按队列的操作来实现。
程序流程图:详细代码:#include <>#include <>#include <>#include <>#define m 4 查看排队情况 *";cout<<endl<<" * 1 . 订票 *"; cout<<endl<<" * 2 . 退票 *"; cout<<endl<<" * 3 . 查看剩余票 *";}void makenull_piao(){FILE *fp;int i;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);}void makenull_information(){node *r;FILE *fp;int i,j,sum;sum=a[1].seat[0]+a[2].seat[0]+a[3].seat[0]; fp=fopen("","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;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->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;}}}void makenull_wait(){wait *tempw;FILE *fp;tempw=new wait;int i;if((fp=fopen("","r")) ==NULL ){fp=fopen("","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("","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;}}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<<endl;}else cout<<endl<<"The "<<i<<" plane is full !"<<endl<<endl;}}void list_information(){int x;do {cout<<endl<<"显示哪架飞机的信息"; cin>>x;cout<<endl;}while(x<1 || x>=m);cout<<endl<<"第 "<<x<<" 架飞机的信息如下 "<<endl;if(x==1) plane_information(head1);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<<"飞机空,无预订票 !"<<endl;}while(q!=NULL){cout<<endl<<"*******************"<<endl;q->date=q->plane;cout<<"日期 :"<<q->date<<endl;cout<<"座位号 : "<<q->seat<<endl;cout<<"姓名 : "<<q->name;cout<<endl<<"ID 号 : "<<q->id;q=q->next;x++;if (x % 3 ==0) 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<<"**** 超出范围!****"<<endl<<"请重新输入:"; }else{cout<<endl<<"你要订的是到"<<i<<"地的飞机"<<endl;cout<<endl<<"第 "<<i<<" 架飞机剩余的票 :"<<endl;for(p=1;p<=n;p++)if (a[i].seat[p]==0) cout<<" "<<p;cout<<endl;break;}}while(1);cout<<endl<<"请选择座位号 : ";do {cin>>j;if (j<1 || j>n) {cout<<endl<<"**** 超出范围!****"<<endl<<"请重新输入:"; }else{q->date=i;cout<<endl<<"您的订票日期 : "<<q->date<<endl;break;}}while(1);if (a[i].seat[j]==0) {a[i].seat[j]=1;cout<<endl;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{ cout<<endl<<"**** 对不起,该座位已被预订,您被安排到订票等候队列****"<<endl;add_wait(i,j);}}void add_wait(int x,int y){wait *tempw;tempw=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=wait_end;wait_end=wait_end->next;cout<<endl<<"**** 正在排队等候 ****"<<endl;wait_head->count++;write_to_file();}void show_wait(){wait *tempw;tempw=wait_head->next;if (tempw==NULL) cout<<endl<<"排队中没有人!"<<endl;while(tempw!=NULL){cout<<tempw->name<<" - ";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>>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;}void search_delete(int x){node *p,*q,*r;wait *tempw,*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<<"请输入个人信息"<<endl;cout<<"*************"<<endl;cout<<endl<<"姓名 : ";cin>>p->name;do{q=q->next;if ( (q!=NULL) &&(comp(q,p)) ){cout<<endl;q->date=q->plane;cout<<"Located!"<<endl;cout<<"****************";cout<<endl<<"姓名 : "<<q->name;cout<<endl<<"ID号 : "<<q->id;cout<<endl<<"座位号 : "<<q->seat;cout<<endl<<"班机号 : "<<q->plane;cout<<endl<<"日期 : "<<q->date<<endl;if (x==1) {cout<<"删除该纪录 [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);cout<<endl<<"等候的人中有可以订票的了:"<<endl; cout<<endl<<"姓名 : "<<tempw->name;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)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;else tempw->next->pre=tempw2;delete(tempw);wait_head->count--;write_to_file();cout<<endl<<"等候的"<<tempw3->name<<"已经成功订票,已经由电话"<<tempw3->phone<<"通知了"<<endl;break;}}}}continue;}else{if (q==NULL){step++;if(step==2) q=head2;if(step==3) q=head3;if(step==4) {cout<<endl<<"**** 信息检索完毕 ****";break;}}}}while(1);}bool comp(node *x,node *y){node *p,*q;int i,j,k;p=x;q=y;i=j=0;do{while ( (p->name[i] != q->name[j]) && (p->name[i] != '\0') ) 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;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("","w");for (i=1;i<=m-1;i++){fwrite(&a[i],sizeof(piao),1,fp);}fclose(fp);fp=fopen("","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++){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("","w");for(j=0;j<=wait_head->count;j++){if(tempw==NULL)break;fwrite(tempw,sizeof(wait),1,fp); tempw=tempw->next;}fclose(fp);}。