C语言飞机订票系统

上传人:s9****2 文档编号:512606376 上传时间:2022-12-24 格式:DOC 页数:22 大小:362KB
返回 下载 相关 举报
C语言飞机订票系统_第1页
第1页 / 共22页
C语言飞机订票系统_第2页
第2页 / 共22页
C语言飞机订票系统_第3页
第3页 / 共22页
C语言飞机订票系统_第4页
第4页 / 共22页
C语言飞机订票系统_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《C语言飞机订票系统》由会员分享,可在线阅读,更多相关《C语言飞机订票系统(22页珍藏版)》请在金锄头文库上搜索。

1、课程:数据结构专业班级:xx软件工程xx班姓名:xx学号:xxx姓名:xxx学号:xxx设计时间:xxx指导老师:xxx曲為CT#课程设计题:飞机订票系统一、设计目的1 .掌握结构体数组的表示和存储。2.掌握链表的存储和操作。3 .掌握文件的操作。二、设计内容和要求1.任务:通过此系统可以实现如下功能:录入:可以录入航班情况(数据可以存储在一个数据文件中,数 据结构、具体数据自定)查询:可以查询某个航线的情况(如,输入航班号,查询起降时 间,起飞抵达城市,航班票价,票价折扣,确定航班是否 满仓);可以输入起飞抵达城市,查询飞机航班情况;订票:订票情况可以存在一个数据文件中,结构自己设定。可以

2、订票,如果该航班已经无票,可以提供相关可选择航班;退票:可退票,退票后修改相关数据文件;客户资料有姓名,证件号,订票数量及航班情况,订单要有编号。修改航班信息:当航班信息改变可以修改航班数据文件。要求:根据以上功能说明,设计航班信息,订票信息的存储结端 St ”呎 构,设计程序完成功能 设计思想:管理操作系统,主要考虑的是信息的录入,这里利用文件的读写完成该 功能;输出,查询以及删除,利用结构数组存储航班与客户信息,依次 对订票,退票,查询及相关操作编写成子程序,然后再主程序中调用, 这样程序看起来相当简练,而且易读懂;算法设计分析:(次系统运行环境为 VC6.0)1.txtbeiji ngs

3、ha nghai 1 1 12 0 1 1 18 06 100 2sha nghaiwuha ng 2 2 12 0 2 2 14 02 110 1wuha ng chibi 3 3 13 0 3 3 14 01 50 2(此文件是程序执行航班信息录入时自动生成,在信息读取时需要调 用)首先是航班于客户信息的存储,结构数组的利用很好的解决该问题; 其次是文件的操作,在主函数中利用文件的读与写;下面介绍订票退票端矗”呎以及查询操作的实现。1订票:首先输入出发地与目的地,查找是否有相应的航班信息,在航2班票数足够的情况下,录入客户信息,提示操作成功;否则失败。3退票:输入退票客户的姓名与身份号码,

4、查找到该客户信息后进行退 票操作,完成后对应航班票数加1;若没有该客户信息,提示查无此人。查询:输入客户姓名与身份号码,若查到有该客户信息,显示该客户的 航班情况;否则提示差无此人。/飞机定票管理系统#in clude#i ncludevwi ndows.h#defi ne N 10struct flightchar start10; 出发地int s_month;/出发时间月份,天,小时,分钟int s_day;int s_hour;int s_mi nute;int d_month;/到达时间月份,天,小时,分钟int d_day;int d_hour;int d_minu te;int

5、coast_t;/ 历时多久int coast_m; 票价int num;/剩余票数/int bia nhao;/ 机票编号airN;结构体数组存储航班信息/客户信息struct conint number;/定票者的证件号码char start10;出发地char en d10; 目的地int s_month;/出发时间月份,天,小时,分钟int s_day;int s_hour;int s_mi nute;int d_month;/到达时间月份,天,小时,分钟int d_day;int d_hour;int d_minu te;int coast_t;/ 历时多久int coast_m;/

6、 票价/ int bianhao;/ 机票编号people100;/定票,输出发地与目的地,时间,反馈剩余票,票价book(i nt t)int i,mo nth,day,p,q,k=O;/k为判断输入的信息是否有误printf(定票:n);/输入查询的航班信息,以便搜索while(k=O)printf(请输入出发地,目的地,出发日期:n);/*gets(start);gets(e nd);/*这里输入时应注意用回车键否则默认字符串存入 start*scan f(%d,%d,&mo nth, &day);/*/sca nf(%s,%s,%d,%d,start,e nd,&mo nth, &da

7、y);/ getchar();pri ntf(%s,%s,%d,%d,start,e nd,mo nth,day);/扫描信息,搜索与所查询的航班匹配信息for(i=0;iN;i+)p=strcmp(start,airi.start);q=strcmp(e nd,airi.e nd);if(p=0&q=0&mon th=airi.s_ month&day=airi.s_day)k=1;/信息输入无误,即找到匹配信息printf(由%s到%s时间为%d月%d号的航班票价为 d,余票为 %dn,airi.start,airi.e nd,airi.s_mo nth,airi.s_day,airi.c

8、oast_m,airi. nu m);/更新信息,将客户信息存储if(airi.num=O)printf(票已售完,如有不便请谅解!nnnn);elseairi. num=airi. nu m-1;printf(请输入您的证件号码与姓名:n);scan f(%d,%s,&peoplet. nu mber,peoplet. name);getchar();strcpy(peoplet.start,airi.start);strcpy(peoplet.e nd,airi.e nd);peoplet.s_ mon th=airi.s_mo nth;peoplet.s_day=airi.s_day;p

9、eoplet.s_hour=airi.s_hour;peoplet.s_mi nu te=airi.s_mi nu te;peoplet.d_ mon th=airi.d_ mon th;peoplet.d_day=airi.d_day;peoplet.d_hour=airi.d_hour;peoplet.d_mi nu te=airi.d_mi nu te;peoplet.coast_t=airi.coast_t;peoplet.coast_m=airi.coast_m;/peoplet.bia nhao=airi.bia nhao;printf(恭喜您定票成功!nnnn);t+;/ sys

10、tem(pause);if(k=O)printf(信息输入有误n);printf(是否继续定票?0为继续1为退出n);scan f(%d,&k);getchar();return t;/退票,并将客户信息栏中该客户信息清楚,所乘航班票数加1re_ti(i nt t)int i,j,n u_mber,k=0;/k为判断是否查找到客户信息char n a_me10;printf(退票:n);printf(请输入证件号码与客户姓名:n);scan f(%d,%s, &nu_ mber, na_me);getchar();for(i=0;i100;i+)if(nu_ mber=peoplei. nu

11、mber&strcmp( na_me,peoplei. name)=0)k=1;找到该客户信息/退票后,与该客户对应航班票数增1for(j=0;jN;j+)if(strcmp(peoplei.start,airj.start)=0&strcmp(peoplei.e nd,airj.e nd)=0&peoplei.s_ mon th=airj.s_ mon th&peoplei.s_day=airj.s_day)airj. num=airj. nu m+1;/将客户信息依次向前移动for(j=i;j100;j+)/ prin tf( 成功删除该客户信息!n);peoplej. nu mber=p

12、eoplej+1. nu mber;strcpy(peoplej. name,peoplej+1. name); strcpy(peoplej.start,peoplej+1.start);strcpy(peoplej.e nd,peoplej+1.e nd);peoplej.s_ mon th=peoplej+1.s_ mon th; peoplej.s_day=peoplej+1.s_day;peoplej.s_hour=peoplej+1.s_hour;peoplej.s_mi nu te=peoplej+1.s_mi nu te; peoplej.d_ mon th=peoplej+1

13、.d_ mon th; peoplej.d_day=peoplej+1.d_day;peoplej.d_hour=peoplej+1.d_hour;peoplej.d_ minu te=peoplej+1.d_ minu te; peoplej.coast_t=peoplej+1.coast_t;peoplej.coast_m=peoplej+1.coast_m;t=t-1;/删除该客户信息后,客户记录减去1if(k=0)printf(查无此人!n);prin tf(nnnn);return t;/查询信息,出入所要查询的顾客的航班信息,并给出错误处理check()int i,n u_mber,k=O;/k为判断是否查找到客户信息char n a_me10;printf(查询:n);printf(请输入证件号码与客户姓名:n);/ getch();fflush(stdi n);scan f(%d,%s, &nu_ mber, na_me);for(i=0;i100;i+

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 活动策划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号