c语言飞机订票系统设计_第1页
c语言飞机订票系统设计_第2页
c语言飞机订票系统设计_第3页
c语言飞机订票系统设计_第4页
c语言飞机订票系统设计_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、课程设计说明书学 院、系:专 业:学生姓名:学号:设计 题目:飞机订票系统设计起迄日期:指导教师:日期:2017年5月12日i1设计目的(1) 实现航班的设定、航班信息的浏览和航班的查询。(2) 实现乘客的飞机票的订购、退票以及所定票的查询。2任务概述本飞机共有80个坐位,分20排,每排4个位子。编号为 A, B, C, D。如10D表示10排D座。A和D靠窗,19到20排为吸烟区。本系统可让乘客自己选座号和区域直到乘客满 意为止,无法满足的话,只能改乘另一个航班。定上票的乘客需给出姓名和身份证号,最后要打印出 乘客清单。3模块划分图3-1功能模块图4主要函数说明及其N-S图 (1)主菜单函数

2、:功能的选择(2)航班设定函数:设定航班数量、航班的起始点、航班时间(3)航班浏览函数:按时间查找浏览、按降落地点查找(4)乘客订票函数:乘客姓名、身份证号以及所定航班的所有信息1、无烟区函数2、吸烟区函数(5)乘客退票函数:航班号、姓名和身份证号(6)乘客信息浏览:乘客姓名、身份证号、座位号和航班号(7)文件保存(8)文件载入(9)退出飞机订票系统N-S图1、航班设定输入新增航班数i输入航班号,起飞和降落地点以及时间和最大载客量Max售票数num图4-1航班设定 N-S图2、输入客户信息输入飞机的 Pi.ID , Pi.BePlace , Pi.EndPlace , Pi.Data , Pi

3、.Max图4-2输入客户信息N-S图234、乘客订票5程序运行数据及其结果图5-1主菜单图5-2航班设定CsUs e rsu-&erllC>es ktopXUntit I ecil.exep L曰-AIS H rInput Lih hiumJlvuwF f XXglliiit士p L C JI M Kin好11: t: he in rnx*ffn-n 1c inn ZInpu't L11H ±H无 f11五等htI n put;the;FllJit; ID:I in puL喏hepLcACH 。£ bt9 H £】jj JL«a&g

4、t;u =三kcw1 nipaj It七1IK妙工乱整日 oF RnrUjt 1 ncie"-:hVUI n puCit 1-iet; Ine of 力e1gr±n =1 2I rhpuL七heM-eLX音= £11.匕音-B0pLeginuInjpm 七 Uhut fljLgh 七I npuCt; heF1U ID =I n piu t七heplatTH o F ife-Q iiifiXeicre* "as1 n p4.it:tlwI1L6。个 o F c: n dx> In c- e- ss kAI npuct hie ime of 1)69

5、±jn -13|l nrtiut:ItzheHa. 乂 HE耳七M二图5-3航班浏览(?!?!?!?Velcome To The Refund Ticket WindowCCP?nIeAse input yoiwflightID number:p21please input yournane :que please input yoiti*Idcard number:123Flight ID Beinplace EndPlace Beffint imeTKe nunber of youhuy w21(iuue121The sm:cess is Ref undine. Press an

6、y key to continue*图5-5乘客退票C:LJ S#耳 £工工。6 匕 tdtOpLI Fit Isxc-Natine a占d.I doaLi*<d.1234j回11L116 I n£ o)1'iTi-a.t ioni Of £hI.日s e art 遒,0 w 岳 e At; co Iule©±2Cea- Itiirn >TH&fliffhtNO322图5-6售票信息浏览6课程设计心得通过这次C语言的课程设计,首先让我回忆和重新巩固 C语言方面的知识,其次让我明白了做 任何事情不可能一次性成功,只有不

7、断地练习,不断地改正、思考才能做出自己的东西。这次的实 验也是很好磨炼我们意志的机会,因为数个小时都待在机房,让我们提前体验自己专业的工作方式。C语言是我们学习的一种基本语言,无论是在以后的学习还是工作中都有非常重要的作用和不可替 代的作用。这次 C语言的课程设计并不是我学习 C语言的结束,而是一个真正的开始。通过这次的课程设计,不仅让我重新认识或是了解到C语言它的强大功能以及多年来一直作为最受欢迎的一种语言的魅力。总之,这几天虽然累,但看着自己做出程序运行的成果,辛辛苦苦编出的代码能顺利的运行心里还是十分欣喜的。附录#include <stdio.h>#include <s

8、tring.h>#include <stdlib.h>#define N 100int NowFlynum,NewFlynum;/ 当前航班数和新增航班数int r;/全局变量实现某个航班的所有票数增加int e=0;/全局变量用于浏览航班和售票信息typedef struct plane char ID10;/ 航班号char BePlace10; / 起飞地点char EndPlace10; / 降落地点char Data15;/ 起飞时间int Max; /最大乘客量int num; /已售票数PLANE;PLANE PN;typedef struct costomer

9、char name10; / 乘客姓名char IDnumber20; / 乘客身份证号char id20; / 乘客所在的航班号int seatrow;/ 乘客所选的座位排号char seatcolumn5;/ 乘客所选的座位的列号COSTOMER;COSTOMER COSN;void menu(); / 主菜单函数void input(int); / 输入航班具体信息void Enter(); / 输入航班设定void print_one_plane(int);/所有设定的航班信息void print_one_plane_and_costomer(int);/乘客订票后的相关信息void

10、print_one_costomer(int);/乘客的个人信息void dele(int);/ 具体删除信息int Delect(struct plane);/ 寻找乘客所要退票的航班int Browse();/ 浏览航班信息void search_time();/ 根据时间查找航班void search_flight();/ 根据降落地点查找航班void Meun1();/查找航班菜单int search();/订票中查找航班void Booking();/ 订票void Refund();/ 退票浏览已售票信息在订票时浏览航班void BrowseInformation();/void

11、save();/保存文件void load();/载入文件void beforeboookingBrowse();/ int main()menu(); void menu()/* 主菜单 */int a,b;/* 中间变量,为了进行功能的选择*/dosystem("cls");printf("*nnn");printf("The Airline ticket system of Taiyuannn");printf("1.Input the new flightn");printf("2.browse

12、the flightn");printf("3.Query the flightn");printf("4.Bookingn");printf("5.Refundn");printf("6.Browse the information we have ticketsn");printf("7.Saven");printf("8.Loadn");printf("9.Exitnnn");printf("*n");printf(&q

13、uot;Input your choice number(1-9):");scanf("%d",&a);if(a>9|a<1)b=1;printf("The number of your input is wrong.Please input again:"); getchar();elseb=0;while(b=1);switch(a)case 1:Enter();break;case 2:Browse();break;case 3:Meun1();break;case 4:Booking();break;case 5:R

14、efund();break;case 6:BrowseInformation();break;case 7:save();break;case 8:load();break;case 9:exit(0);void Enter()/* 输入航班设定*/system("cls");void input(int);NewFlynum=0;NowFlynum=NowFlynum+NewFlynum;printf("Please input the number of flight:n");scanf("%d",&NewFlynum);

15、printf("please input the information:" );for(int i=0;i<NewFlynum+NowFlynum;i+)printf("nplease input the %dst flightn",i+1); input(i);getchar();menu();void input(int i)/* 输入航班具体信息*/printf("Input the flight ID:n");scanf("%s",Pi.ID);printf("Input the plac

16、e 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");scanf("%d",&Pi.Max);Pi.num

17、=0;int Browse()/* 浏览航班信息*/int i;r=0;system("cls");printf("ntThe FlightBrowse");printf("nt FlightID Beginplace EndPlace Begintime The Max costomer num The number of sale n");for(int i=0;i<NewFlynum+NowFlynum;i+)r=r+Pi.num;for(int i=0;i<NewFlynum+NowFlynum;i+)print_

18、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(" %s %s %s %s%d%d n",Pi.ID,Pi.BePlace,Pi.EndPlace,Pi.Data,Pi.Max,Pi.num);void print_one_constomer(int

19、t)/* 乘客订票后的相关信息*/printf("nt FlightID Beginplace EndPlace Begintime The number of booking The sold tictetsn");printf(" %s %s %s %s%d%d(row)%s(column)n",Pt.ID,Pt.BePlace,Pt.EndPlace,Pt.Data,1,COSe.seatrow,COSe.seatcolumn );void Meun1()/* 查找航班菜单*/int a,b;do system("cls");p

20、rintf("ttttttThe Operation Of Sale Ticketsnn");printf("tt*MENU1*nn");printf("nntt*n");printf("tttt1.Look for the flight as time.n");printf("tttt2.Look for the flight as place.n");printf("tttt3.Return the menu;n");*printf("Input your ch

21、oice number(1-3):"); scanf("%d",&a);if(a<1|a>3)b=1;printf("Your choice is wrong!please input again:");getchar();getchar();else b=0;while(b=1);switch(a)case 1:search_time();break;case 2:search_flight();break;case 3:menu();break;void search_time()/* 根据时间查找航班*/int m=0

22、;struct plane s;system("cls");printf("nplease input the time:");scanf("%s",s.Data);printf("");printf("ntFlightID Beginplace EndPlace Begintime The Max costomer num The number of salen");for(int i=0;i<NewFlynum+NowFlynum;i+)/ 与所有的航班进行比较if(strcmp(s.

23、Data,Pi.Data)=0) print_one_plane(i); printf("n");printf("n");printf("Press any key to continue");getchar();getchar(); Meun1(); void search_flight()/* 根据降落地点查找航班*/int m=0;struct plane s;system("cls");printf("nplease input flight:"); scanf("%s&quo

24、t;,s.EndPlace); printf("n");printf("ntFlightID Beginplace EndPlace Begintime The Max costomer num The number of sale n");for(int i=0;i<NewFlynum+NowFlynum;i+)if(strcmp(s.EndPlace,Pi.EndPlace)=0)/与所有的降落地点进行比较print_one_plane(i);printf("n");printf("n"); printf

25、("Press any key to continue");getchar();getchar(); Meun1(); void Booking()/* 订票*/void compare();/重复的输入void chooseNS();/ 无烟区 void chooseS();/吸烟区r=0;int i;/ 选择变量int a=0;/ 循环变量int choose;char w;int d=-1;/ 选择变量struct plane s;/ 声明一个结构体变量system("cls");printf("tttWelcome To Thec Ti

26、cket Windown");printf("ttIt have 20 rows ,every row has 4 seats,'A','B','C','D'.ntt'A' and'D' are close the window.19 and 20 are smokingplace.");printf("nplease input your flightID number:n");scanf("%s",s.ID);for(int

27、m=0;m<NowFlynum+NewFlynum;m+)/* 循环找到要浏览的航班*/if(strcmp(s.ID,Pm.ID)=0)d=1;break;if(d=1)printf("nnDo you want to browse the information of salenplease input -y- to continue,or -n- exitnn");scanf("%s",&w);if(w='y')/ 选择是否要进行已售票信息的浏览beforeboookingBrowse();printf("Do

28、 you want a seat of Smoking or NoSmoking:nnplease 1 for Smoking,2 for NoSmoking: ");scanf("%d",&choose);if(choose=1)chooseS();i=search();elsechooseNS();i=search();if(i!=-1)if(Pi.num>=Pi.Max) printf("This filght's tickets has been sold over!"); else Pi.num+; strcpy

29、(COSe.id,Pi.ID); e+;printf("nntttSuccess booking!n"); elseprintf("This flight is no exist!"); printf("Press any key to continue");getchar();getchar(); menu(); elseprintf("The flight is no exist!please booking again!n"); void compare()printf("Input error,c

30、olumn 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:nn");scanf("%s",COS);printf("nn");printf("p

31、lease input your Idcard number:nn");scanf("%s",COSe.IDnumber);printf("nn");printf("please input the ticket of number you want:nn");printf("row:");scanf("%d",&row);for(int a=0;)if(row>18|row<1)printf("Input error,row cann't mor

32、e 18!please input again or please return and choose Smoking!n");printf("row:");scanf("%d",&row);elseCOSe.seatrow=row;break;printf("column:");scanf("%s",COSe.seatcolumn);for(int a=0;)if(strcmp(COSe.seatcolumn,"A")=0|strcmp(COSe.seatcolumn,&qu

33、ot;B")=0|strcmp(COSe.seatcolumn,"C")=0|strcmp(COSe.seatcolumn,"D")=0)/判断是否有输入错误COSe.seatcolumn;break;elsecompare();void chooseS()int row;printf("nnplease input your name:nn");scanf("%s",COS);printf("nn");printf("please input your Idca

34、rd number:nn");scanf("%s",COSe.IDnumber);printf("nn");printf("please input the ticket of number you want:nn");printf("row:");scanf("%d",&row);for(int a=0;)if(row>20|row<18)printf("Input error,row cann't more 20 and less 18!ple

35、ase input again or please return and choose Smoking!n");printf("row:");scanf("%d",&row);elseCOSe.seatrow=row;break;printf("column:");scanf("%s",COSe.seatcolumn);for(int a=0;)if(strcmp(COSe.seatcolumn,"A")=0|strcmp(COSe.seatcolumn,"B&quo

36、t;)=0|strcmp(COSe.seatcolumn,"C")=0|strcmp(COSe.seatcolumn,"D")=0)COSe.seatcolumn;break;elsecompare();void beforeboookingBrowse()int i;r=0;system("cls");printf("ntThe FlightBrowse");printf("nt FlightID Beginplace EndPlace Begintime The Max costomernum The

37、 number of sale The sold tictetsn");for(int i=0;i<NewFlynum+NowFlynum;i+)r=r+Pi.num;for(int i=0;i<e;i+)print_one_plane_and_costomer(i);printf("n");printf("tn");printf("Press any key to continue ");getchar();getchar();void print_one_plane_and_costomer(int i)pr

38、intf(" %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,C OSi.seatcolumn);int search()/* 订票中查找航班*/int k,t=0;struct plane s;k=-1;printf("Input the place of beginplace:n");scanf("%s",s.BePlace);printf("Input the place

39、 of endplace:n");scanf("%s",s.EndPlace);printf("Input the time of begin:n");scanf("%s",s.Data);for(int i=0;i<NewFlynum+NowFlynum;i+)/* 判断输入的信息与已存在的信息是否匹配*/if(strcmp(s.BePlace,Pi.BePlace)=0&&strcmp(s.EndPlace,Pi.EndPlace)=0&&strcmp(s.Data,Pi.Data)

40、=0)k=i;strcpy(s.Data,Pi.Data);printf("nntttttInformation as follow:n");print_one_constomer(t);t+;break;if(k=-1)printf("nnNo exist!");return -1;elsereturn k;void Refund()/* 退票 */void print_one_plane1(int); int k=-1;int i;struct plane s;/system("cls");char name20;char num

41、ber;printf("Welcome To The Refund Ticket Windown");printf("please input your flightID number:n");scanf("%s",s.ID);printf("please input your name:n"); scanf("%s",name);printf("please input your Idcard number:n");scanf("%s",&num

42、ber);for( i=0;i<NewFlynum+NowFlynum;i+)/ 查找航班号 if(strcmp(s.ID,Pi.ID)=0) k=i;printf("ntFlightID Beginplace EndPlace Begintime The number of you buyn");print_one_plane1(k); break; if(k=-1) printf("nnNo exist!"); elsePi.num-;/总票数减一Delect(s);printf("nThe success is Refunding.

43、n"); printf("Press any key to continue");getchar();getchar();menu();void print_one_plane1(int 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)/ 判断输入的航班号de

44、le(i); return i;void dele(int k)/* 具体删除信息*/int i;for(i=(k+1);i<N;i+)strcpy(COS,COSk+1.name);strcpy(COSk.IDnumber,COSk+1.IDnumber);strcpy(COSk.id,COSk+1.id);void BrowseInformation()/* 浏览已售票信息*/int i;system("cls");r=0;for(i=0;i<NewFlynum+NowFlynum;i+) r=r+Pi.num;printf("ntThe Information OfSalen");printf("nt Name Idcard seatrow seatcolume TheflightNOn");for(i=0;i<r;i+)printf(" %s %s %d(row)%s(column) %sn",COSi. name,COSi.IDnumber,COSi.seatrow,COSi.seatcolumn,COSi.id);prin

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论