




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、课程设计说明书学 院、系:专 业:学生姓名:学号:设计 题目:飞机订票系统设计起迄日期:指导教师:日期:2017年5月12日1设计目的(1)实现航班的设定、航班信息的浏览和航班的查询。(2)实现乘客的飞机票的订购、退票以及所定票的查询。2任务概述本飞机共有80个坐位,分20排,每排4个位子。编号为A, B, C, Do如10D表示10排D座。A和D靠窗,19到20排为吸烟区。本系统可让乘客自己选 座号和区域直到乘客满意为止,无法满足的话,只能改乘另一个航班。定上 票的乘客需给出姓名和身份证号,最后要打印出乘客清单。3模块划分结构体(飞机和乘客)菜单功能选择函数航班设定函数飞机订票系统设计航班浏
2、览函数乘客订票函数按航班时间查找函数按降落地点查找函数吸烟区函数无烟区函数乘客退票函数 浏览乘客订票信息保存信息 载入信息图3-1功能模块图4主要函数说明及其N-S图(1)主菜单函数:功能的选择(2)航班设定函数:设定航班数量、航班的起始点、航班时间(3)航班浏览函数:按时间查找浏览、按降落地点查找(4)乘客订票函数:乘客姓名、身份证号以及所定航班的所有信息1、无烟区函数2、吸烟区函数(5)乘客退票函数:航班号、姓名和身份证号(6)乘客信息浏览:乘客姓名、身份证号、座位号和航班号(7)文件保存(8)文件载入(9)退出飞机订票系统N-S图1、航班设定输入新增航班数i输入航班号,起飞和降落地点以及
3、时间和最大载客量Max售票数num图4-1航班设定N-S图2、输入客户信息输入飞机的 Pi. ID, Pi.BePlace, Pi. EndPlace, Pi. Data, Pi. Max图4-2输入客户信息N-S图输出航班 输出航班 信息信息不存输出信息/ 在M班输H 存在信,航班图4-3浏览航班信息N-S图4、乘客订票输入航班号Pi. ID,乘客的COSe. name, COSe. number, COSe. seatStrcmp(s. ID , Pm. ID) m+否beforeboookingBrowse);int choose_=l-否chooses ();chooseNS ();
4、否* 该航班票数已售完 印出购票信息订票成功!图4-4乘客订票N-S图5、乘客退票输入航班号Pi. ID,乘客的COSe. name,是s退票成功信息输入有误图4-5乘客退票N-S图5程序运行数据及其结果图5-1主菜单图5-2航班设定 C:U5er5u5er llDesktopUntitledl.exe-T he A ii*lino t; ickot; system of TaiyuanCl . Input Che no v/ flight;【Nl.hicsac 七 he F lijyht:L3 the £ 1 l«htI 4 1 . Boo15 J.RefundFG 3
5、. Bvov/sc tzhe Inf ovmnt; Ion vjc hcivc CdLckeHs £7J .StveEft 1 -LoadL9 J.ExitI nput:c li<> ice nti rilie? t*< X 9 > : 1 C:U5er5u5erl lOc5ktopUntit ledl.exPloascIn vut tzhcnumbci* o £ fa e:input: die*in ci'ecC i on :pl cc fa <*:icfput: elmlat f liaBt:I npt1 七七hef 13f、七I
6、D:I 11 1>IA Ct Jie1> JLcc eof Jje«f ifiIace :MVJI nttliepX<*v e?of onUpJLQ.ee:we1 n pu tChotImo 。£ 力*gin:121 n pu tt hoMax 8eat;8 :80plc*rt neInjpttlrZat £1士号】、CI nptt tClmFlinHt:ID =322I npn 七mA W*七heP 1CG CoF Hnjyinp lace 5%r111 PIA tliep JLu eof wnUpX«.ce :uU1 11t七het
7、 irie u£ JjoqWn,JL31 | V>l,ttheMax soata 图5-3航班浏览图5-4机票订购(?(?(?(?We leone To The Refund Ticket Window(?ee(? please input your flight ID number: w21 please input your name :plea.se input your I de ar d number: 123Flight ID Beginplace EndPlace BegintimeThe nunber of youbuy w21qwwe121The succes
8、s is Refunding.Pp-ess any key to continue图5-5乘客退票图5-6售票信息浏览6课程设计心得通过这次C语言的课程设计,首先让我回忆和重新巩固C语言方面的 知识,其次让我明白了做任何事情不可能一次性成功,只有不断地练习, 不断地改正、思考才能做出自己的东西。这次的实验也是很好磨炼我们意 志的机会,因为数个小时都待在机房,让我们提前体验自己专业的工作方 式。C语言是我们学习的一种基本语言,无论是在以后的学习还是工作中都有 非常重要的作用和不可替代的作用。这次C语言的课程设计并不是我学习C语言的结束,而是一个真正的开始。通过这次的课程设计,不仅让我重新认识或是
9、了解到C语言它的强大 功能以及多年来一直作为最受欢迎的一种语言的魅力。总之,这几天虽然 累,但看着自己做出程序运行的成果,辛辛苦苦编出的代码能顺利的运行 心里还是十分欣喜的。附录#include <stdio. h>#include <string. h>#include <stdlib. h>#define N 100int NowFlynum, NewFlynum;当前航班数和新增航班数int r;int e=0;全局变量实现某个航班的所有票数增加 全局变量用于浏览航班和售票信息typedef struct planechar ID10;char BeP
10、lace 110;char EndPlace10;char Data15;int Max; int num;航班号起飞地点降落地点起飞时间最大乘客量己售票数PLANE;PLANE PN;typedef struct costomerchar name 10; 乘客姓名char IDnumber20; 乘客身份证号char id20; 乘客所在的航班号intseatrow; 乘客所选的座位排号char seatcolumn5;乘客所选的座位的列号 COSTOMER;COSTOMER COSN;void menu();主菜单函数void input (int); 输入航班具体信息void Ente
11、r ();输入航班设定void print_one_plane (int);所有设定的航班信息void print_one_plane_and_costomer (int);乘客订票后的相关信息void print_one_costomer (int);乘客的个人信息void dele(int);具体删除信息int Delect (struct plane); 寻找乘客所要退票的航班int Browse。;浏览航班信息void search_time (); 根据时间查找航班void search_f light ();根据降落地点查找航班void Meunl ();查找航班菜单int sea
12、rch。;订票中查找航班void Booking。;订票void Refund。;退票void Browseinformat ion ();浏览己售票信息void save。;保存文件void load。;载入文件void beforeboookingBrowse ();在订票时浏览航班int main()menu ();) void menu ()/*主菜单*/int a, b;/*中间变量,为了进行功能的选择*/ dosystem(cls);printfCviz vlx sixkIz kIx kIxkIzkIz vfzKLX sJxKLZ six KLXkIz sJx kIz six xl
13、zkIznnn);printfCTaiyuannn);printfCprintfCThe Airline ticket system of/卜 /卜 4、4、4、-卜 V、-卜 4、卜 4、/卜 4、-卜 4、/卜 4、4、4、卜 4、/卜 4、/卜 4、卜 4、/卜4、-卜 4、/卜 4、-卜 4、一卜 4、/卜 4、/卜 4、卜 4、/卜4、-卜 4、/4 4、-卜 4、/卜 4、/卜 4、/卜 4、/卜 4、/卜 ,卜 1、1 . Input the new flightn,z);2 . browse the flightnz,);printf (,z3. Query the fligh
14、tn);printf("4. Bookingn);printf (z/5. Refundn);printf (,z6. Browse the information wehave tickets'n");printf ("7. Saven,/);printf("8. Loadn);printf (,z9. Exitnnn");printfCKLZ kZz kIxxfx kIzkIxK1X sfz kIx vfz kIz kZz kIx卜吸、/卜 4、4、4、.卜乙、.卜 4、/卜 4、/ 4、/卜 4、-卜 4、/、4、/卜 4、/卜
15、4、/卜 4、/卜 4、/卜 4、/卜 4、卜 4、/卜 4、/卜 4、/卜 4、/卜 4、/卜 4、/卜 4、/卜 4、卜 4、/卜 4、/卜 4、/卜 4、/卜 4、/卜 力、/卜 4、/卜 4、-卜 n);printf ("'Input your choice number (1-9):);scanf(%d, &a);if (a>9 a<l)( b二l; printf("The number of your input is wrong. Please input again:");getchar (); else b=0;whi
16、le(b=l);switch(a)(case 1:Enter();break;case 2:Browse();break;case 3:Meunl();break;case 4:Booking();break;case 5:Refund();break;case 6:Browselnformation();break;case 7:save ();break;case 8:load();break;case 9:exit(0); ) void Enter ()/*输入航班设定*/system("cis");void input (int);NewFlynum=O;NowF1
17、ynum=NowF1ynum+NewF1ynum;printf CzPlease input the number of flight: n,/);scanf(%d”, ftNewFlynum);printf ("please input the information:;for(int i=0;i<NewF1ynum+NowF1ynum;i+) (printf (z,nplease input the %dst flightn,i+1); input (i);getchar ();menu ();)void input (int i)/*输入航班具体信息*/printf (&
18、quot;Input the flight ID: n,z);scanf (s", Pi. ID);printf("Input the place of beginplace:n); scanf(s, Pi. BePlace);printf ("Input the place of endplace: n,/);scanf(s",Pi. EndPlace);printf("Input the time of begin:n); scanf (s, Pi. Data);printf ("Input the Max seats: n,?)
19、;scanf(d,&Pi. Max);Pi. num=0;)int Browse () /*浏览航班信息*/11 / 27int i;r=0;system("cls);printf (ntTheFlight Browse);printf(nt FlightID Beginplace EndPlace Begintime The Max costomer num The number of sale 'n");for(int i=0;i<NewF1ynum+NowF1ynum;i+)(r=r+Pi. num;for(int i=0;i<NewF1y
20、num+NowF1ynum;i+)(print_one_plane(i);printf(n);printf("tn);printf ("Press any key to continue);getchar ();getchar ();menu ();return i;) void print_one_plane (int i)/*所有设定的航班信息*/printf (z/%s%s%s%s%d%dn,Pi. ID,Pi.BePlace, Pi. EndPlace, Pi. Data, Pi. Max, Pi. num); )void print_one_constomer (
21、int t)/*乘客订票后的相关信息*/ printfC?nt FlightID Beginplace EndPlace Begintime The number of bookingThe sold tictetsn,/);printf (%s%s%s%s%d%d (row) %s (column) n,P t. ID, P t. BePlace, P t. EndPlace, P t. Data, 1, COS e. seat row, COSLe. seatcolumn);) void Meunl ()/*查找航班菜单*/int a, b;do(system(cls);printf (z
22、,ttttttThe Operation Of Sale Ticketsnn);printf (z/tttt 1. Look for the flight as time. n);27 / 27printf (/ztttt 2. Look for the flight as place. n,z);printf (z,tttt 3. Return the menu; n,z);printf (Z/Input your choice number (13) :,z); scanf (%d, &a);if(a<l a>3)b=l;printfC'Your choice
23、is wrong!please input again:");getchar ();getchar ();)else b=0;while(b=l);switch(a)(case 1:search_time();break;case 2:search_flight();break;case 3:menu();break;)void search_time () /*根据时间查找航班*/ -int m=0;struct plane s;system("cls);printf(z,nplease input the time:");scanf (s”, s. Data)
24、;printfC,)-printf(ntFlightID Beginplace EndPlace BegintimeThe Max costomer num The number of salen,/);for (int i=0; IXNewFlynum+NowFlynum; i+) 及所有的航班进行比较 (if (strcmp(s. Data, Pi. Data) =0)print_one_plane (i);printf CW);)printfCn);printf (,zPress any key to continue);getchar ();getchar ();Meunl ();)v
25、oid search_flight ()/*根据降落地点查找航班*/int m=0;struct plane s;systemC'cls);printf (,znplease input flight:,z);scanf(s,s. EndPlace);printfCn);printf("ntFlightID Beginplace EndPlace Begintime The Max costomer num The number of sale n);for(int i=0;i<NewF1ynum+NowF1ynum;i+)if (strcmp(s. EndPlace,
26、 Pi. EndPlace) =0)及所有的降落地点进行 比较print_one_plane (i); printf CW);printfC);n) printf ("'Press any key to continue getchar (); getchar ();Meunl ();) void Booking。/*订票*/void compare。;重复的输入void chooseNS ();无烟区void chooseS();吸烟区r=0;int i; 选择变量int a=0;循环变量int choose;char w;int d=T;选择变量struct plane
27、s;声明一个结构体变量system("cls);printf("tttWelcome To Thee Ticket Windown);printf (,zttlt have 20 rows , every row has 4seats, ' A' , ' B' , ' C' , ' D' . ntt' A' and ' D' are close the window. 19 and20 are smokingplace.,z);printf CAnplease input you
28、r flightID number: n,z);scanf (%s, s. ID);for (int m=0;m<NowFlynuni+NewFlynum;ni+)/*循环找到要浏览的航班*/ if (stremp (s. ID, Pm. ID) =0)(d=l; break; ) if (d=l) (printf (z,nnDo you want to browse the information of salenplease input -y-一 to continue, or n- exitnn);scanf(s, &w);if (w=' y')选择是否要进
29、行已售票信息的浏览 (beforeboookingBrowse();printf (,zDo you want a seat of Smoking or NoSmoking: nnpleasefor Smoking, 2 for NoSmoking: );scanf(d”, &choose);if(choose=l)(chooseS ();i=search(); else chooseNS (); i二search。;if(i!=-l)(if (Pi. num>=Pi. Max) printf (,zThis filght, s tickets has been sold ove
30、r!,z);) else Pi. num+;strcpy (COS e. id, Pi. ID); e+;printf (,znntttSuccess booking! nz,);) else (printf ("This flight is no exist!z,);printf ("Press any key to continue);getchar ();getchar ();menu ();)elseprintf (,zThe flight is no exist!please booking again! nz,);)void compare()printf(&q
31、uot;Input error, column must be 'A', 'B','C or ' D'. !please input again!n);printf("column:);scanf(%s,COSe. seatcolumn);void chooseNS() int row;printf (nnplease input your name: nnz/);scanf(s, COSe. name);printf Cnn,z);printf ("please input your Idcard number: n
32、n,/);scanf(s, COSe. IDnumber);printf(nn);printf (z,please input the ticket of number you want: nn,z);printfCrow/);scanf(%d”, &row);for(int a=0;) if(row>18| row<l) (printf("Input error, row cann,t more 18!please inputagain or please return and choose Smoking!n");printf Crow:/z);sc
33、anf(d, &row);) else COSe. seatrow=row;break; ) )printf("column:");scanf(%s, COSe. seatcolumn);for(int a=0;) if(strcmp(COSe. seatcolumn, =0 Istrcmp(COSe. seatcolumn, “B)=0 strcmp(COSe. seatcolumn,=0| |strcmp(COSe. seatcolumn, D)=0)判断是否有输入错误C0Se. seatcolumn;break;elsecompare ();)void cho
34、oseS()int row;printf Cznnplease input your name:nn");scanf(%s, COSe. name);printf(nn);printf ("please input your Idcard number: nn,/);scanf(s”, COSe. IDnumber);printf Cnnz);printf ("'please input the ticket of number you want: nn,z);printf ("row:");scanf(%d, &row);fo
35、r(int a=0;)if(row>20 row<18)printf ("Input error, row cann,t more 20 and less 18iplease input again or please return and choose Smoking! n,z);printf Crow:0 ;scanf(d, &row);)else COSe. seatrow=row;break;)printf("column:);scanf("%s,COSe. seatcolumn);for (int a=0;)if(strcmp(COS
36、e. seatcolumn, =0 Istrcmp(COSe. seatcolumn, B)=0 strcmp(COSe. seatcolumn, C")=0| |strcmp(COS Fe. seatcolu mn,D")=0)C0Se. seatcolumn; break;) else ( compare (); ) )void beforeboookingBrowse() int i;r=0;system("cls);printf (ntThe FlightBrowse);printf("nt FlightID Beginplace EndPlac
37、e Begintime The Max costomer num The number of saleThe sold tictetsnz,);for (int i=0;i<NewF1ynum+NowF1ynum;i+)(r=r+Pi. num;for(int i=0;i<e;i+)(pr i nt_one_p1ane_and_c o s t omer(i);printf(n);printf ("tn);printf("Press any key to continue );getchar ();getchar ();)void print_one_plane_
38、and_costomer(int i) -printf(%s%s%s%s%d%d%d (row)%s (column) n”,Pi. ID,Pi.BePlace, Pi. EndPlace, Pi. Data, Pi. Max, Pi. num ,COSi. seatrow, COSi. seatcolumn);)int search ()/*订票中查找航班*/ int k, t=0;struct plane s;k =-1;printf("Input the place of beginplace:n); scanf (s,s. BePlace);printf ("Inp
39、ut the place of endplace: n,z);scanf(s,s. EndPlace);printf("Input the time of begin:n);scanf (s,s. Data);for (int i=0; i<NewF 1 ynum+NowF 1 ynum; i+)/*判断输入的信息及已存在 的信息是否匹配*/(if (strcmp(s. BePlace, Pi. BePlace) =0&&strcmp(s. EndPlace, Pi. E ndPlace)=0&&strcmp(s. Data, Pi. Data)
40、=0)k二 i;strcpy (s. Data, Pi. Data);printf (,znnttttt Informat ion as follow: n,z);print_one_constomer (t);t+;break;)if(k=-l)(printf(nnNo exist!”);return _1;elsereturn k;)void Refund。/*退票*/void print_one_planel(int);int k=-l;int i;struct plane s;/system(,cls,/);char name20;char number;printf(Welcome
41、To The Refund TicketWindown);printf ("please input your flightID number: n,/);scanf (%s, s. ID);printf (/zplease input your name: nz,);scanf(s, name);printf (,zplease input your Idcard number: n,z);scanf(s, &number);for ( i=0; i <NewF 1 ynum+NowF 1 ynum; i+) 查找航班号(if(strcmp(s. ID,Pi. ID)
42、=0)k二 i;printf (,zntFlightID Beginplace EndPlaceBegintimeThe number of you buyn);print_one_planel(k);break;)if(k=-l)( printf (nnNo exist!z,); else ( 总票数减一 Delect (s);printf (nThe success is Refunding. n,?);printf (,zPress any key to continue);getchar ();getchar (); menu ();)void print_one_planel (in
43、t i) 信息的输出函数printf(%s%s%s%s%dn,Pi. ID, Pi. BePlace, Pi. EndPlace, Pi. Data, 1);)int Delect (struct plane a)/*寻找乘客所要退票的航班*/ int i;for(i=0;i<N;i+)(if (strcmp(a. ID, COSi. id) =0)判断输入的航班号 dele (i);)return i;void dele (int k)/*具体删除信息*/int i;for(i=(k+l) ;i<N;i+)(strcpy(COSk. name, COSk+1. name);strcpy(COSk. IDnumber, COSk+1. IDnumber);strcpy (COS k. id, COS k+1. id);) void Browse Informat ion () /*浏览己售票信息*/ int i;system("cls);r=0;for(i=0;i <NewF1ynum+NowF1ynum;i+)r=r+Pi. num;printf (?,ntThe Information OfSalen);printf(nt Name Idcard seatrow seatcolumeThef 1 i ghtNO nz,);fo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025电影剧本创作聘用合同模板
- 2025房产不动产抵押合同范本:商业地产项目抵押融资
- 请假条写作课件
- 红酒杯知识培训总结课件
- 2025标准机械设备采购合同书样本
- 语言基础知识培训简报课件
- 2025农业作物种子买卖服务合同
- 2025制片合同范本模板
- 2025出国留学合同
- 在线支付服务接入合作协议
- 2025年中级消控笔试题目及答案
- 2024年中国防锈油行业调查报告
- 办公软件培训课件
- 成人氧气吸入疗法-中华护理学会团体标准
- 2025年职业指导师(中级)考试试卷:职业指导师考试备考策略
- 2025年度辅警招聘考试题(含答案)
- 初三心理健康教育开学第一课
- 初一新生入学教育
- 卫生院健康检查管理制度
- 高二秋季开学第一课班会课件:启航高二把握未来
- 山地绿化工程的安全防范措施
评论
0/150
提交评论