


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、第一章实习报告§ 1.1题目描述【要求】假定某民航机场共有 n个航班。每个航班有一航班号、确定的航线(起始站、终点站)、 确定的飞行时间(星期几)和一定的成员订额。试设计一民航订票系统,能提供下列服务。(1) 航班信息录入功能(航班信息用文件保存)。(2)航班信息浏览功能。(3)查询航线:(至少一种查询方式)。 按航班号查询。 按起点站查询。 按终点站查询。 按飞行时间查询。【提示】(1 )需求分析航班信息用文件保存, 因而要提供文件的输入/输出功能;要浏览航班信息,需要提供显示功能;要查询航线,需要提供查找功能;另外,还要提供键盘式选择菜单以实现功能 选择。(2)总体设计整个系统可
2、以设计为航班信息输入模块、航班信息浏览模块和航线查询模块。(3)数据结构建立航班结构体,结构体成员包括航班号、起始站、终点站、飞行时间(星期几)、预售票总数、已售票数。§ 1.2算法设计根据需求分析,可以将这个系统的设计分为如下五大模块:输入航班信息,保存航班 信息,浏览航班信息,查找航班信息,退出。飞机订票系统输入航班信息浏览航班信息§ 1.3程序设计及代码分析1.结构体设计建立航班结构体,结构体成员包括航班号,起点站,终点站,飞行时间(星期几),预售票 总数。struct air int fir_num;char start20;char term inu s20;ch
3、ar fir_time10;int count;sN; /*sN中每个数组元素依次对应一个航班信息*/注意sN 中的N为学生个数,程序中采用宏定义的方式,可以随时在源程序宏定义中改 本程序宏定义 # define N 10000。2主函数流程图程序 void mai n() int j ;printf(“ -welcome to our scheduled flight man age system!-*n”);printf(“ *n”);do pri ntf(“ 1. Please in put the scheduled flight in formati onnm?“ 2. Look t
4、hrough the scheduled flight in formatio nnn?“ 3. Search for the scheduled flight in formati onnn?“ 0. EXITnn ” );printf(“ *n”);printf(“ NOTE: This system just support the fly informationin the nearestweek!nn ” );printf( “ Please choose one number during 0-3 then push enter: nn” );scanf( “ d , &j
5、 );switch (j) case 1: in put(); break;/*调用输入模块*/case 2: prin t(); break;/*调用打印模块*/case 3: search(); break;/*调用查找模块*/case 0: break;while(j!=0);/*退出*/printf(“Thank you for using our system!Goodbye!n” );3.各功能模块设计3.1输入航班信息流程图程序void in put() char f= int y; printf ( scanf(“20121000748”/*设置密码*/“ Please in
6、put the password the n push En ter:nn “s ,f);/*读取密码“20121000748”)= =0)“ Please in put the flight*/”);if(strcmp(f, printf(ticket should be en ded by 0):nninformationone by one(the number of the”);printf( “ *nfor(i=0;i<N;i+) printf(scanf( printf( sca nf( printf( scanf( printf( sca nf( printf(“ Plea
7、se in put the flight nu mber:n"%d' ,&si.fir_num);“ Please in put the start place:n“ s ,si.start);/*“ Please in put the term inu s:n"%s ,si.terminus); /*“ Please in put the time:n“ %s ,si.fir_time);/*/*”);读取航班号*/”);读取起点站*/);读取终点站*/);读取时间*/“ Please in put the nu mber of the ticket(th
8、e nu mber of the ticket should be ended by 0:)n”,m);scanf(“ d',&si.count);/*读取机票数*/”);m+;printf(“ The %d group informationto con ti nue, push 0 to the end”scanf(if(y= =0) save();prin t();break; else printf(Goodbye!nn“d',&y);/*/*“ password);have bee n in putted!Please push any key,m);
9、将结构体存盘 输入输出航班信息*/*/error! Please check your password!Tha nk you!3.2保存信息模块流程图程序void save() FILE *fp, *fp1;/*定义文件指针*/if(fp=fopen(“ chen.dat ” , ” wb" )= =NULL) /*打开文件并判断是否出错*/ printf(“ Fail to creat the file!'nn” );getchar();return;if(fp仁fopen(“hao.dat ” , ” wb" )= =NULL) printf(“ Fail t
10、o creat the file!nn” );getchar();return;for(i=0;i<m;i+)if(fwrite(&si,sizeof(structair),1,fp)=0) /*向文件写入数据并判断是否出错*/printf( “ Fail to in put data to the file!' nn” );fprintf(fp1,” %d ,m);fclose(fp); /*关闭文件 */fclose(fpl);3.3浏览信息模块流程图定义文件指针N |从文件中读取信息关闭文件打印信息程序void read()定义文件指针*/ FILE *fp, *f
11、p1;/*if(fp=fopen(“ chen.dat ” , ” rb ” )= =NULL) /*打开文件判断是否出错*/ printf( “ Error please make sure the file is exist! Push any key back to the menu );getchar();if(fp仁fopen("hao.dat ” , ” rb ” )= =NULL) /*打开文件判断是否出错*/ printf(“ Fail to creat the file!nn” );getchar();return;fscanf(fp1, ” d ,&m);
12、fclose(fp1);for(i=0;i<m;i+)从文件中读取信息*/ fread( &si,sizeof(s),1,fp);/*fclose(fp);/*关闭文件 */void print()/*打印模块 */ char w10;read();/*调用读文件函数*/printf( “ FlightNumber StartPlace Terminus Time TicketNumbern” );for(i=0;i<m;i+) printf(PRINT); /*打印信息 */printf( “ Please push any key back to the up menu
13、:n” );scanf(“s ,w);3.4查询信息模块流程图程序void search。 char name120;char name220;char ii10;char time10; int n,no;doprin tf("Pleasechoose one way you want to searchnn");/*打印查询方式菜单*/prin tf("1.Accord ing to the flight nu mber nn""2.According to the Terminusnn""3.Accord ing to
14、 the start placenn""4.According to the flying timenn" "0.BACK nn");printf("Please choose one number during 0-3: nn""Push any other key back to the top men u:nn ”);scanf("%d",&n);/*读取查找方式 */if(n= =0)break; switch( n) case 1:prin tf("Please in
15、 put the flight nu mberscan f("%d",&no);/*break;:n ”);航班号*/case 2:prin tf("Please in put the term inus scan f("%s", name2);/*break;case 3:n");读取终点站*/prin tf("Please in put the start place scan f("%s", name1);/*break;case 4:prin tf("Please in put
16、the flying time:n");读取起点站*/:n");scan f("%s",time);break;read();/*调用读取函数*/for(i=0;i<m;i+)if(strcmp(si.start ,n ame1)=0|strcmp(si.term inus,n ame2)=0)/*按终点站起始站判断输出条件*/prin tf("nSucceed in search ing for the flight in formati on !n");prin tf("FlightNumber StartPlac
17、e Terminus TimeTicketNumber n");printf(PRINT);/*打印信息 */if(si.fir_ num= =n o) /*按航班号判断输出条件 */prin tf("nSucceed in searchi ng for the flight in formati on!n");prin tf("FlightNumber StartPlace Terminus Time TicketNumbern");prin tf(PRINT);if(strcmp(si.fir_time,time)= =0)prin tf(
18、"nSucceed in searchi ng for the flight in formati on!n");prin tf("FlightNumber StartPlace Terminus Time TicketNumbern");printf(PRINT);/*打印信息 */prin tf("Ca n not find the in formti ong you wan ted or youhave done it : nn""Do you want to con ti nu e?Please in put YES
19、 or NOand push en ter n ”);scan f("%s",ii);while(strcmp(ii,"yes")=0);§ 1.4实验数据及运行效果截图1.输入数据管理员输入航班信息航班号起点站终点站飞行时间总票数100quzhouwuha n9.1100101quzhouwuha n9.2150102wuha nquzhou9.1130103beijingwuha n9.21002. 编译,连接和运行3. 结果3.1主菜单函数3.2输入信息模块护他啟査2砖ktop'Oebug工15序讓计 奚浒舌QSLL220 了朗c
20、 忙九血护 凶韋査0«如砒6氐 或实浒吉08口223再筈T3ic 1 ruujj infornliun hae Jbeii injjulld»ui0 tc the Gnd:input:thef lihitnuimheF :101P lensexnpuittJtca tertplace Pw MinnPleaseinphLlttheit 丄#rdnti 空:hrtilbniiPleaaetiltt me :L<1Pipa-!?*81i mpLitpunhR>qf rhe rickstCThfib fD;riii nilcp “F tThpg尸oup inl oin
21、at ion hau<s Jbeen inputted ! Please puh the endt Cr*叶Hr ahniJIfl he F?ndpri han ksy to coritinLW.pu#9ias » IgTQ匚 p inf 03左 tM-Qn hacfllbo廿 n i.npu 斤ctA性"ploptlApEIh U bQft-hol ondM-*nMUfT-Ehfll旳 3-ihlt nllnlhcl""2°32key 軒。GG5cti3ubclpu!lHftdw僅 1-IIL £*<Jn A-liEL
22、i g 詈s' WEi-nyuitLhnWudr-L 匸dcffialirrre3昂!mumbIxiF* 口*!Itllffi*tic-ke17At*h£sllnhm'so 中rt'reJhio 3ulp. 口匚 p in* Dlrrker-iDIn hpcaJblDflln inpu 存ctad fp.La&«ipuis:hQfflort-lw4i3d曲 n 审匕 Mo! conctl-l-3ule% ppttJl3.3浏览信息模块 C:UJi®C-esktopDebuq ASWrh 克习按青 DSLL22-O7xeN-H K4K
23、卄 K«rN XWJTtO-IC*! MH X <KWWWW>rlC N H K !WWWWC> K 餐 M耳X « WW*fX*r X WK WfctX MWWWMW-K l*MWTEs Thia systopi Juvt support th* f 1 irformtijon in thonoroBt: ho ok fitFl ease cfiooe one miohei* diirtorH-31 tlienentei*= 1F1 i 日 JiltHuLnib f驚 iarti, lac oionmknklngrI Hihe IJinyL62s-hai
24、iglkiiL03wuhgiinPlosLt pu嘗Ji any M昏y back to the'£ ai'niJius yuhanRlllddi «rJLi|<Ul nankin up RenuTlir»IickotHunbor1OAISAsee1U03.4查询信息模块f :>: iir-.- C;-5 Z:_ CD. C| :.'±.T- .1-1 12- 0 . zMOTE: Thiv cyctpijutt 百 uppoiMt the f 1 inf crrotijon in t ha> neayeet h
25、o ok T T TPlease cbmiDes cncnunbcr lLirini«r 03 J thciii push entiEr: JMdi* you 阳nt to search-1 nccor<lliri<(tOKtllOF 丄 ihtntinbor? Ai riii-il liiiijtllHTr nvlneisJ dice ordinifttio4. Ar:ruri1 Imgto>tllf lyidngt inPle<ne ckioosc oneid.IffiCMPlHdKe t:ijiih ni.n«liei" ilurlu
26、y B-4;Puoh v sthoi' key back to tho top i*oniu?#=3.4.1按照航班号查询342按照终点站查询3.4.3按照起点站查询3.4.4按照时间查询pi41 li 劑"v l>AL;k tu thcs Lup iwemuxA1PleaifF inynt1.2rlhe f lying tlnsp ;tjucceed in sesusliiri日 Foh tkef 1 in ht inf ontai iorh fFllhtNiimiJbiieF1Star-tPliSijceI enlnusTineT loke t Himbei*IOS
27、ridiikinyWLihdfi111UL>uccced in scwelling Co 1s- theIliribt infoiLnat ion?FlKt a*tPl*teI&rnifiUS11m1九 cketI Alhftlj IngMli It Ani15BGucccad in sccurcliim For* tlicriLnht infornat ion.!FlLSfhtNunkborStartPlacQloninuoTiiwIicicotHiuibor102shanghaimilt an1Z2ORSucceed in sccLrchincr for thef 1 ijn
28、ht inf urnat ton?P1 LQfhtzNuimibe! rtilartPlajce1 srniiiiuijB1 insT ickot Hujitbei*LU2u>ia.nghaikiuhari1Z2UldkucLEcd in scoruliiny Cor tlicf liiihL Irif urviat lurafF1 ighrGtartPldicc1 erniliurincT iclcc t HunkerL»Jnnikin1.2midOn nat FimdInfamrlnn©艸u OAntri cm* ponIuur 曲ltdit:rDo voi 罰n
29、tcantinuc?Ploiac Ln put VEG or HOand pushenter半 弋:伽护凶當澤叭IdQpig bug疋歸送计黨习报舌OS 1122-07 «xe';l 二345 结束 X:U5PT5Ai® SxDflsttop'pe tnjgVCSii-OS 1122 -0?xeDecantinueTPloaoa iLnpmt VE£ or HO and puch cntvi1lin1 lc«i®e; in put the schcdu 1cd f light inf o rrn-aLiun2 a.LoiQk thFoutrh the scheduled f l±g(h< i.nif o wiation3 .GcirGFi Fcr ths sci
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 考研政治面试题库及答案
- 农业产业园项目2025年区域农业产业结构优化研究与效益评估
- 基于2025年视角的资源型城市产业升级与绿色发展报告
- 2025年特色主题餐厅餐饮市场区域差异与竞争策略研究报告
- 数字化驱动2025:公路货运行业效率提升与可持续发展报告
- 安全教育培训记录缺失课件
- 共享厨房在促进餐饮消费升级方面的实践与探索报告
- 服装设计师品牌方案
- 租赁物品使用协议格式
- 2025年医药电商平台药品供应链金融合规性分析与运营优化报告
- 德瑞斯D600变频器说明书
- 2025-2030年中国锂电池回收行业市场深度调研及前景趋势与投资研究报告
- 数字化教育资源在跨学科教学中的应用
- JG/T 127-2017建筑门窗五金件滑撑
- T/CGCC 7-2017焙烤食品用糖浆
- 2024福建农信社春季招聘笔试历年典型考题及考点剖析附带答案详解
- 医生重症医学科进修汇报
- DB13(J)-T 8389-2020 被动式超低能耗建筑节能工程施工及质量验收标准
- 月嫂 考试题及答案
- 物质安全资料脱模剂MSDS
- 2025年中国过敏性鼻炎市场研究报告
评论
0/150
提交评论