




免费预览已结束,剩余17页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
数据结构课程设计-航空客运订票系统一、问题描述:航空客运订票的业务活动包括:航线查询、客票预定和办理退票等。试设计一个航空客运订票系统、以使上述业务可以借助计算机来完成。二、基本要求(1)每条航线所涉及的信息有:终点站名、航班号、飞机号、飞行周日(星期几)、乘员定额、余票量、已订票的客户订单(包括姓名、订票量、舱位等级1,2或3)以及等候替补的客户名单(包括姓名、所需票量);(2)作为示意系统,全部数据可以只放在内存中;(3)系统能实现的操作和功能如下: a、查询航线:根据旅客提出的终点站名输出下列信息:航班号、飞机号、星期几飞行、最近一天航班的日期和余票额; b、承办订票业务:根据珂护提出的要求(航班号、订票数额)查询该航班票额情况,若有余票,则为客户班里订票手续,输出作为好;若已满或者余票少于订票额,则需要重新询问客户要求。若需要,可等级排队侯补; c、承办退票业务:根据客户提供的情况(日期、航班),为客户办理退票手续,然后查询该航班是否有人排队侯补,首先询问排在第一的客户,若所退票额能满足他的要求,则为他办理订票手续,否则一次询问其他排队侯补的客户#include #include #include #include #include #include #define MAX 50#define NULL 0typedef struct Customer /*已定票乘客信息*/ char Name7; /*姓名*/ int Amount; /*定票数*/ char Rank; /*舱位等级*/ int Seat_No; /*座位号*/ struct Customer *Next;Customer;typedef struct Replace /*替补乘客信息*/ char Name7; /*姓名*/ int Amount; /*定票数*/ char Rank; /*舱位等级*/ char Seat_No; /*座位号*/ struct Replace *Next;Replace,*PReplace; typedef struct Flight /*航线信息*/ char Des_Name10; /*终点站名*/ char Flight_No6; /*航班号*/ char Plane_No6; /*飞机号*/ char Week_Day; /*飞行周日*/ int Customer_Amount; /*乘员定额*/ int Free_Amount; /*剩余票数*/ int Price3; /*舱位等级的价格*/ Replace *ReplName; /*该航班的候补乘客名单*/ Customer *CustName; /*该航班的已定票乘客名单*/ struct Flight *Next; /*指示下一航线结点*/Flight,*PFlight;int Customer_Count=0; /*所有航线的定票乘客总数*/Flight *Head; /*航线头指针*/Flight *p2; /*航线结点指针*/Customer *Custp1MAX; /*各条航线乘客结点指针*/Replace *Replp1MAX; /*各条航线候补结点指针*/int IsEmpty=1; /*是否有定票乘客*/int IsReplace=1; /*是否有候补乘客*/Customer *prior; /*满足要求的定票乘客的前结点,以作删除操作*/FILE *fp; /*文件指针*/int shouldsave=0;char Continue() char answer; while(1) printf(nt Do you want to contiune(Y/N)?); scanf(%s,&answer); system(cls); if(answer=y|answer=Y) return y; else if(answer=n|answer=N) return n; else printf(ntThe input is error,please input again!); /*-操作出错函数-*/void ErrorMess() printf(ntSorry,there is no menu!); getch();/*-系统退出-*/int ExitSystem() char answer; printf(nt Do you want to exit(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; char c; p1=Head; if(Head=NULL) printf(ntThere is no plane to the place!);getch(); return; printf(ntPlease input the Des_Name:); scanf(%s,&p2-Des_Name); printf(ntThe planes information:n); printf(n*n); while(p1!=NULL) if(strcmp(p1-Des_Name,p2-Des_Name)=0) printf(Des_Name Flight_No Plane_No Week_Day Cust_Num Free_Num 1_Price 2_Price 3_Pricen); printf(n%-9s%-10s%-9s%-9c%-9d%-9d%-8d%-8d%-8d,p1-Des_Name,p1-Flight_No,p1-Plane_No,p1-Week_Day, p1-Customer_Amount,p1-Free_Amount,p1-Price0,p1-Price1,p1-Price2); 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(ntAdd the Flight line!n); printf(ntPlease input Des_Name:); scanf(%s,&p2-Des_Name); while(1) /*数据合法性检验*/ printf(ntPlease input the only Flight_No:); scanf(%s,&p2-Flight_No); if(Find_Line(Head,p2-Flight_No) /*存在航班号*/ printf(ntThe Flight_No is not only!n); else break; printf(ntPlease input the Plane_No:); scanf(%s,&p2-Plane_No); while(1) printf(ntPlease input the fly date(weekday):); scanf(%s,&p2-Week_Day); if(p2-Week_DayWeek_Day7) printf(ntThe data is wrong,please input again!n); else break; printf(ntPlease input the Plane_seat Number:); scanf(%d,&p2-Customer_Amount); printf(ntPlease input the First class Price:); scanf(%d,&p2-Price0); printf(ntPlease input the Second class Price:); scanf(%d,&p2-Price1); printf(ntPlease input the Third class Price:); scanf(%d,&p2-Price2); 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(ntSorry,there is no Flight Line,Please Return!); getch(); return 1; else return 0;/*-航线查看函数-*/void Line_See() system(cls); Flight *p1; p1=Head; if(Empty_Flight() /*航班线为空*/ return; printf(nntThe planes information:n); printf(n*n); printf(Des_Name Flight_No Plane_No Week_Day Cust_Num Free_Num 1_Price 2_Price 3_Pricen); while(p1!=NULL) printf(n%-9s%-10s%-9s%-9c%-9d%-9d%-8d%-8d%-8d,p1-Des_Name,p1-Flight_No,p1-Plane_No,p1-Week_Day,p1-Customer_Amount,p1-Free_Amount,p1-Price0,p1-Price1,p1-Price2); p1=p1-Next; printf(n*n); printf(ntPress any key to return!n); getch(); void Sub1Menu() char c; system(cls);printf(nttThe flight manage menu:);printf(n*nn);printf(t1.Add the flight linen);printf(t2.Search the flight linen);printf(t3.Look over the flight linen);printf(t4.Return to the menun);printf(n*n);printf(tPlease choose:); scanf(%s,&c); switch(c) case 1:Line_Add();break;case 2:Line_search();break; case 3:Line_See();break; case 4:return; /*-订票办理函数-*/void Sub2Menu() int Ticket_Count,Seat_No,i,flag=0; int Flight_No=0; /*记录满足条件的航线的定票结点*/ Flight *p1; /*记下满足条件的航线结点地址*/ Customer *p2; /*临时性定票乘员结点*/ Replace *p3; /*临时性候补乘员结点*/ char answer7; /*用户输入的航班数据*/ char temp; char c; int tag=0; /*候补乘客标志位*/ int IsRepl=0; /*是否执行候补操作标志位*/ if(Empty_Flight() /*航班线为空*/ return; while(1) printf(ntBook the ticket!); flag=0; /*标志位清零以重新作出判断*/ Flight_No=0; tag=0; printf(ntPlesae input the Flight_No:); scanf(%s,&answer); if(Find_Line(Head,answer,p1,Flight_No) /*调用航线查找函数,若存在则进行以下操作*/ while(1) /*数据合法性检验*/ printf(ntPlease input the Num what you want to book:); scanf(%d,&Ticket_Count); if(Ticket_Count=0) printf(ntPlease input the Num again:n); getch(); else break; if(p1-Free_Amount=Ticket_Count) Customer_Count+; /*定票乘客总数增1*/ flag=1; /*表明进入了订票实际操作*/ IsRepl=1; /*定票量满足,无需进入候补操作*/ if(p1-CustName=NULL) /*首个定票乘客,并记录相关属性*/ Custp1Flight_No=p2=new Customer; /*建立该航线的首位乘客结点*/ p1-CustName=Custp1Flight_No; else /*建立该航线的后续乘客结点*/ p2=new Customer; Custp1Flight_No-Next=p2; Custp1Flight_No=p2; IsEmpty=0; /*定票乘员不为空*/ Custp1Flight_No-Amount=Ticket_Count; /*订票数*/ Seat_No=p1-Customer_Amount-p1-Free_Amount+1; /*算出座位号*/ Custp1Flight_No-Seat_No=Seat_No; /*赋座位号*/ p1-Free_Amount-=Ticket_Count; /*减去定票数*/ printf(ntPlease input your name:); scanf(%s,&Custp1Flight_No-Name); while(1) /*数据合法性检验*/ printf(ntPlease input the Class Num:); scanf(%s,&Custp1Flight_No-Rank); if(!(Custp1Flight_No-Rank=1&Custp1Flight_No-RankSeat_No); if(Ticket_Count10) /*为显示规整,作相应处理*/ printf(nt); else printf(nt); for(i=1;iFree_Amount=0) printf(ntSorry,there is no ticket!n); IsRepl=0; else printf(ntSorry,there are not many tickets you want!n); IsRepl=0; if(!IsRepl) printf(ntDo you want to be a replace passager(Y/N)?); scanf(%s,&temp); if(temp=y|temp=Y)/*以下为候补操作*/ if(p1-ReplName=NULL) Replp1Flight_No=p3=new Replace; /*建立该航线的首位候补乘客结点*/ p1-ReplName=Replp1Flight_No; else p3=new Replace; Replp1Flight_No-Next=p3; Replp1Flight_No=p3; IsReplace=0; /*候补乘客不为空*/ tag=1; /*已选择列入候补乘客名单*/ Replp1Flight_No-Amount=Ticket_Count; printf(ntPlease input your Flight_No:); scanf(%s,&Replp1Flight_No-Name); Replp1Flight_No-Seat_No=Seat_No; /*候补乘客的座位*/ Replp1Flight_No-Amount=Ticket_Count; /*候补乘客的订票数*/ while(1) /*数据合法性检验*/ printf(ntPlease input the Class_No:); scanf(%s,&Replp1Flight_No-Rank); if(!(Replp1Flight_No-Rank=1&Replp1Flight_No-RankNext=NULL;/*末位定票乘客的指针置空*/ if(tag) Replp1Flight_No-Next=NULL;/*末位候补乘客的指针置空*/ printf(nt It is success!n); printf(ntDo you want to leave:(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(ntThe passagers list); if(IsEmpty) printf(ntSorry,there is none passager!n); getch(); return; printf(n*n); printf(Name Flight_No Plane_No Tic_Amount Des_Name Rank_No Seat_Non); 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-Seat_No); if(p2-Amount1) printf(nntThere has more tickets!n); else printf(nntThere is no ticket!n); p2=p2-Next; p1=p1-Next; printf(nn*n); printf(ntPress any key to return!); getch(); return;/*-候补乘客信息-*/void Display_Replace() system(cls); Flight *p1; Replace *p2; p1=Head; if(Empty_Flight() return; printf(ntThere is no replace people list!); if(IsReplace) printf(ntSorry,There is no replace passager!n); getch(); return; printf(n*n); printf(Name Flight_No Plane_No Tic_Amount Des_Name Rank_No Seat_Non); 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-Seat_No); if(p2-Amount1) printf(tThere has more tickets!n); else printf(tThere is no ticket!n); p2=p2-Next; p1=p1-Next; printf(nn*n); printf(ntPlease press any key to return!); getch(); return;/*-退票办理函数-*/void Sub3Menu() int Flight_No=0,flag=0; /*记录满足条件的航线的定票结点*/ Flight *p1; /*记下满足条件的航线结点地址*/ Customer *p2,*p4; /*临时性定票乘员结点*/ Replace *p3,*p5; /*临时性候补乘员结点*/ char answer7,name7; /*用户输入的航班数据*/ int tag=0; /*若第二乘客满足条件,则它的首地址会发生冲突,注意此处*/ int Seat_No; /*记录座位号*/ if(Empty_Flight() /*航班线为空*/ return; printf(ntRefund the ticket); if(IsEmpty) printf(ntSorry,There is no passager!); getch(); return; while(1) flag=0; tag=0; Flight_No=0; printf(ntRefund the ticket); printf(ntPlease input the Flight_No:); scanf(%s,&answer); if(Find_Line(Head,answer,p1,Flight_No) /*航线存在*/ p2=p1-CustName; /*指向该航线的乘客名单的首地址 */ printf(ntPlease input the name:); scanf(%s,&name); if(p2=NULL) /*该航线无定票乘客*/ printf(ntSorry,there is no passager!.); if(Continue()=n)/*是否继续操作*/ return; else while(p2!=NULL)/*查找有无此乘客名*/ if(strcmp(p2-Name,name)=0)/*此外括号不能省略,否则功能会转变*/ if(p2=p1-CustName) /*若为首位乘客满足*/ prior=p1-CustName; /*记录指针*/ Seat_No=p2-Seat_No; flag=1; break; else if(p2-Next!=NULL)/*记录满足航线的的前结点地址 */ if(strcmp(p2-Next-Name,name)=0) tag=1; /*特别注意此处*/ prior=p2; /*记录满足定乘客的前一地址,以作删除操作*/ Seat_No=p2-Next-Seat_No; flag=1; break; p2=p2-Next; /*指向下一乘客结点*/shouldsave=1; /*while */ if(!flag) printf(ntSorry,there is no passager!n); /*存在该航线*/ else printf(ntSorry,there is no Flight_No!n); if(flag) if(prio
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年建筑施工安全管理信息化在工程项目中的应用案例分析
- 2025年婴幼儿配方食品营养配方优化对婴幼儿视力发育的影响研究
- 2025年城市轨道交通智慧运维系统建设与智能运维管理优化策略深度报告
- 轻化工专业试题及答案解析
- 2025年塔吊维修证考试题及答案
- DB65T 4404-2021 植保无人飞机防治棉花病虫害作业规程
- 敬业专业实践面试题及答案
- 2025年新能源行业企业绿色建筑技术应用与效果分析报告
- 电厂防雷应急预案(3篇)
- 低温工作应急预案(3篇)
- 输血申请单规范PDCA
- 污水处理技术及工艺介绍课件
- 市政工程工程量计算规范课件
- 第17课-我是浙江人课件
- 隐身技术概述课件
- 《红细胞血型系统》课件
- 《太阳出来了》课 件课件
- 《家庭暴力中的正当防卫问题分析(论文)9500字》
- 公路桥梁和隧道工程施工安全风险评估讲解(刘兴旺)
- 人教版七年级音乐下册教学计划(范文五篇)
- 中国主要造船企业分布图
评论
0/150
提交评论