c语言定订票系统
C语言课程设计汽车售票系统

二○一○~二○一一学年第二学期信息科学与工程学院课程设计报告书课程名称:班级:学号:姓名:指导教师:二○一○年九月C语言课程设计题目:汽车售票系统任务:自学C语言中相关知识,设计出汽车售票系统。
要求如下所述:每天“火车站→植物园”有5个班次的汽车(假设),具体的数据格式如下:班次发车时间载客量已售票数1 06:40 50 02 09:30 40 03 12:00 40 04 14:30 40 05 16:00 50 0为售票员开发一个小程序,以完成每天的“火车站→植物园”的售票业务。
要求如下:1. 能够售票和退票。
以文件(myfile.txt)的形式保存当天各个车次的售退票情况。
◆售票功能当查询出已定票人数小于额定载量且当前系统时间小于发车时间时才能售票,自动更新已售票人数。
◆退票功能退票时,输入退票的班次,当本班车未发出时才能退票,自动更新已售票人数。
2. 查询显示功能。
可以随时显示当前售票现状(如:班次发车时间载客量已售票数余票等信息)。
3. 用户界面中的菜单至少应包括“售票”、“退票”、“显示当前售票情况”、“保存当天数据”、“退出”5项。
可适当增加其他附加功能。
主程序流程图:订票程序流程图:退票程序流程图:系统功能模块图:程序概述:主函数菜单包括订票,退票,查看,保存的菜单.由相应函数调用可以实现相关功能模块.订票退票功能基本是一样的,需要分别输出购票车次及张数.查看功能只是把数据输出界面.退出功能是调用系统退出函数来终止程序的运行.函数程序首先要读入文件myfile.txt,获取已订票数的数据,如果没有文件,则会提示打不开文件.英雌运行程序之前请在C盘建立一个TXT文件,名为:myfile.txt.里面的内容不做任何修改,让其保留空白.默认购票数全部为0.主要源程序代码:#include<stdio.h>#include<stdlib.h>int menu() /*主菜单*/{int a;printf("****************************\n");printf("*1、订票*\n");printf("*2、退票*\n");printf("*3、显示订票情况*\n");printf("*4、保存当天数据*\n");printf("*5、退出(请先保存) *\n");printf("****************************\n");printf("******请选择操作*********\n");scanf("%d",&a);return a;}void esc(){exit (0);}void check(int*bus) /*查看车次售票情况的程序*/{printf("车次发车时间载客量已售票\n");printf("1、06:40 50 %d\n",*bus); printf("2、09:30 40 %d\n",*(bus+1)); printf("3、13:00 40 %d\n",*(bus+2)); printf("4、16:00 40 %d\n",*(bus+3)); printf("5、20:50 50 %d\n",*(bus+4)); }void order(int*bus) /*订票功能程序*/{int a,b;int capacity[5]={50,40,40,40,50};check(bus);printf("请选择要订的车次\n");scanf("%d",&a);if(a>5||a<1)printf("你选择了错误的序号\n");else printf("请选择要订票的张数\n");scanf("%d",&b);if(b>capacity[a-1]-*(bus+a-1))printf("你定票的张数超过剩余张数\n");else{*(bus+a-1)+=b;printf("订票成功\n");}}void cancel(int*bus) /*退票功能程序*/{int a,b;check(bus);printf("请选择要取消订票的车次\n");scanf("%d",&a);if(a>5||a<1)printf("你选择了错误的序号\n");elseprintf("请选择要退票的张数\n");scanf("%d",&b);if(b>*(bus+a-1))printf("你退票的张数已超过订票的张数\n");else{*(bus+a-1)-=b;printf("退票成功\n");}}void write(int*bus) /*写入已存数据的程序*/ {FILE *fp;if((fp=fopen("C:\\myfile.txt","wb"))==0){printf("打不开文件\n");exit(0);}fwrite(bus,1,1,fp);printf("保存成功\n");fclose(fp);}void read(int*bus) /*读入已存数据的程序*/{int i;FILE *fp;if((fp=fopen("C:\\myfile.txt","rb"))==0){printf("打不开文件\n");exit(0);}for(i=0;i<5;i++){if(!feof(fp)) /*测试fp所指向的文件当前状态是否"文件结束"*/ fread(bus+i,1,1,fp);}fclose(fp);}void main() /*主函数*/{int bus[5]={0,0,0,0,0};int a;read(bus);a=menu(); /*显示主菜单*/while(a<6){switch(a){case 1:order(bus);break;case 2:cancel(bus);break;case 3:check(bus);break;case 4:write(bus);break;case 5:esc();break;default:printf("你选择了错误的序号\n");break;}a=menu();}write(bus);}调试分析过程:对于购票子程序中,原来没有对购退票的张数与所剩张数做比较,加了相应代码,可以实现相应的错误提醒,然后返回主菜单,重新开始.对于退出函数,是查相应资料,通过调用系统退出函数来实现退出程序.存在问题及思考:在购退票输入要选择的车次的时候,如果输入错误的车次,则会提示”你选择了错误的序号”.但是不会返回上级菜单或主菜单.这个问题还没有解决.尝试过用return函数使其返回,但是反而会引起其他的错误,暂不知如何修改.课程设计小结:C语言是所有现在流行的编程语言的基础.学好C语言,有助于其他的语言的理解及学习.C程序中,核心是算法,只有先写出算法,然后对细节慢慢修改,写程序也应该有个相应的分块,不能就从头开始往下写,而应该先分成相应子块,写出主程序把其他子程序连接起来.然后开始子程序块的编写代码.刚编写成功的程序,肯定是有很多问题的,特别是联系实际情况的,问题就更多了,这就要求我们有很大的耐心来修改程序,并联系实际情况.学好C语言能培养我们的耐心,严谨,的态度,并有良好的基础,为以后的计算机方面的学习提供一定的帮助.我们应该学好C语言.。
C语言程序设计课程设计飞机订票系统的设计

一、设计内容与设计要求一、设计内容:飞机订票系统1.1问题描述:假设某航空公司只有M架N个座位的飞机,每架飞机每天飞行一趟。
通过该系统来实现机票的订购问题。
1.2功能要求:1)、本系统采用一个包含N个数据的结构体数组,每个数据的结构应当包括:起飞地、目的地航班号、座次号码、座次订出与否标记、订座者的姓名和订座者的身份证号码。
2)、本系统显示这样的菜单:(1)输入航班信息(2)输出航班信息(3)查找航班信息a.显示空座的数量b.显示空座的信息c.显示已订座的信息d.起飞时间(4)订票预约(5)删除定票预约(6)退出系统1、本系统成功执行菜单的每个信息,选项4)和5)将要求额外的输入,并且它们都允许用户收回其输入。
2、查找航班信息既可按线路查,也可按目的地查。
4、在两次运行之间,数据被保存于一个文件里,当本程序重新开始的时候,它首先从该文件读入数据1.3 算法提示:1、数据结构:结构体类型数组2、数据库结构:下表构成该系统的基本数据库。
1.4测试数据:每架飞机的座位N=12,M=51.5 其它:对该系统有兴趣的同学可以在实现系统基本功能后,完善系统的其它功能。
二、设计要求1).设计正确,方案合理。
2).界面友好,使用方便。
3).程序精炼,结构清晰。
4).设计报告5000字以上,含程序设计说明,用户使用说明,源程序清单及程序框图。
5).上机演示。
二、进度安排第 18 周星期一上午课题讲解查阅资料星期一下午系统需求分析模块设计星期二上午算法、数据结构设计主程序设计星期二下午各功能模块程序设计修改完善程序星期五下午各功能模块程序设计修改完善程序第 19 周时间待定星期五下午答辩目录一、需求分析 (4)1、程序的功能 (4)2、输入输出的要求 (6)二、概要设计 (9)三、详细设计 (11)1、数据类型 (11)2、模块分析 (12)3、函数的调用关系 (12)四、调试分析以及设计体会 (13)1、测试数据 (13)2、调试分析 (13)3、心得体会 (14)五、使用说明 (15)六、附录 (17)1、参考书目 (17)2、源程序清单(带注释) (17)七、计算机科学与技术系课程设计评分表 (40)一、需求分析1.1 系统功能需求1.1.1程序的功能1.系统管理员功能:1)录入和修改航班和机票的信息:输入航班号,输入起飞港,途径港,到达港,录入起飞时间,到达时间,飞行总共用时,可随时修改航班信息2)输出航班的信息:输入航班号便可输出之前输入的航班信息2.客户需要的功能:1)查找航班信息:a.显示空座的数量b.显示空座的信息c.显示已订座的信息d.起飞时间2)订票预约:查询航班信息后,提前订票预约需要的飞机票,3)删除定票预约4)退出系统1.1.2 主要模块流程图1.1.3 功能描述1.1.4各功能模块的功能描述(1)显示菜单函数:FLIGHT fltlist[5]; PASSENGER psglist[5][12]; ReadFlight(fltlist);PASSENGER* k;k=(PASSENGER*) psglist; ReadPassenger(k);用户可以根据菜单提示,选择相关菜单。
c语言 航空订票系统代码

struct airline *find()
/*根据系统提出的航班号查询并以指针形式返回*/
{ struct airline *info;
char number[10];
int i=0;
info=start;
printf("请输入航班号:");
scanf("%s",number);
if(!(info=find())) return;/*根据客户提供的航班号进行查询,如为空,退出该模块*/
printf("请输入你订票所需要的数量:");
scanf("%d",&amount);
if(amount>info->tkt_amt)/*若客户订票额超过乘员定票总额,退出*/
linkqueue wait;/*等候替补的客户名单域,分别指向排队等候名单队头队尾的指针*/
}lineinfo;
struct airline *start;
struct airline air[MAXSIZE]={{"北京","1","001","SUN",30,15},
{"上海","2","002","MON",40,10},
strcpy(new1->name,name);
new1->ord_amt=amount;
new1->grade=grade;
new1->next=NULL;
if(head==NULL)/*若原无订票客户信息*/
c语言编程 电影院票务系统

电影院票务系统程序设计C语言编程需自行编辑TXT文件1--6#include<stdio.h>#include<stdlib.h>void menu(){FILE *fp;char ch;fp=fopen("menu.txt","r");for(ch=fgetc(fp);ch!=EOF;ch=fgetc(fp))putchar(ch);fclose(fp);}void book(){int a1,b1,c1,d1,m,k;FILE *fp;printf("请输入目标电影序号:(1-6)");scanf("%d",&k);switch(k){case 1:fp=fopen("ticket1.txt","r+");break;case 2:fp=fopen("ticket2.txt","r+");break;case 3:fp=fopen("ticket3.txt","r+");break;case 4:fp=fopen("ticket4.txt","r+");break;case 5:fp=fopen("ticket5.txt","r+");break;case 6:fp=fopen("ticket6.txt","r+");break;default :printf("you enter an wrong number!\n");}fscanf(fp,"%d %d %d %d",&a1,&b1,&c1,&d1);printf(" 电影序号%d 共有座位%d 已卖出%d 剩余%d\n",a1,b1,c1,d1); if(d1<1) printf(" 对不起,票已售完,请下次再来\n");else {printf("确定订票?1(Y)/0(N)\n");scanf("%d",&m);if(m==1) {c1++;d1--;printf(" 谢谢购买!祝您观影愉快!\n"); rewind(fp);fprintf(fp,"%d %d %d %d",a1,b1,c1,d1); }}fscanf(fp,"%d %d %d %d",&a1,&b1,&c1,&d1);fclose(fp);printf(" 电影序号%d 共有座位%d 已卖出%d 剩余%d\n",a1,b1,c1,d1); }void cancel(){int e1,f1,g1,h1,m,w;FILE *fp;printf("请输入目标电影序号:(1-6)");scanf("%d",&w);switch(w){case 1:fp=fopen("ticket1.txt","r+");break;case 2:fp=fopen("ticket2.txt","r+");break;case 3:fp=fopen("ticket3.txt","r+");break;case 4:fp=fopen("ticket4.txt","r+");break;case 5:fp=fopen("ticket5.txt","r+");break;case 6:fp=fopen("ticket6.txt","r+");break;default :printf("you enter an wrong number!\n");}fscanf(fp,"%d %d %d %d",&e1,&f1,&g1,&h1);printf(" 电影序号%d 共有座位%d 已卖出%d 剩余%d\n",e1,f1,g1,h1); if(g1<1) printf(" 对不起您的输入有误,请重试!\n");else {printf("确定退票?1(Y)/0(N)\n");scanf("%d",&m);if(m==1) {g1--;h1++;printf(" 已退票,欢迎下次再来\n"); rewind(fp);fprintf(fp,"%d %d %d %d",e1,f1,g1,h1); }}fscanf(fp,"%d %d %d %d",&e1,&f1,&g1,&h1);fclose(fp);printf(" 电影序号%d 共有座位%d 已卖出%d 剩余%d\n",e1,f1,g1,h1); }void inquire(){int i,j,k,l,t;FILE *fp;printf("请输入目标电影序号:(1-6)");scanf("%d",&t);switch(t){case 1:fp=fopen("ticket1.txt","r+");break;case 2:fp=fopen("ticket2.txt","r+");break;case 3:fp=fopen("ticket3.txt","r+");break;case 4:fp=fopen("ticket4.txt","r+");break;case 5:fp=fopen("ticket5.txt","r+");break;case 6:fp=fopen("ticket6.txt","r+");break;default :printf("you enter an wrong number!\n");}fscanf(fp,"%d %d %d %d",&i,&j,&k,&l);printf(" 电影序号%d 共有座位%d 已卖出%d 剩余%d\n",i,j,k,l);}main(){int c;int w;start:printf(" *************************************\n");printf(" Welcome to our ticket system!\n" );printf(" 1. Movies menu \n");printf(" 2. book the ticket. \n");printf(" 3. cancel the ticket \n");printf(" 4. inquire the ticket \n");printf(" 5. exit \n");printf(" *************************************\n");scanf("%d",&c);switch(c){case 1:menu();break;case 2:book();break;case 3:cancel();break;case 4:inquire();break;case 5:goto end;default :printf("you enter an wrong number!\n");}printf("continue? 1(Y)/0(N) \n");scanf("%d",&w); system("cls");loop:{if(w==1)goto start;else goto end;}end: printf(" Thank you for use my system! Bye!\n\n\n author:percyfan\n\n\n");}。
航空订票系统c语言课程设计

航空订票系统c语言课程设计一、课程目标知识目标:1. 让学生掌握C语言中结构体、数组、函数等基本知识点的综合运用,特别是在航空订票系统中的应用。
2. 让学生了解并掌握航空订票系统的基本业务流程,如航班查询、预订、取消预订等功能。
3. 使学生能够通过C语言实现简单的航空订票系统,并了解其背后的数据结构和算法。
技能目标:1. 培养学生运用C语言进行问题分析、程序设计和调试的能力。
2. 培养学生独立思考和团队协作的能力,通过项目实践,提高解决实际问题的能力。
3. 培养学生具备良好的编程习惯,编写出结构清晰、可读性强的代码。
情感态度价值观目标:1. 培养学生对计算机编程的兴趣和热情,激发他们主动探索新知识的精神。
2. 培养学生面对困难和挑战时,保持积极乐观的心态,勇于克服困难,不断进步。
3. 通过航空订票系统课程设计,使学生认识到编程在实际生活中的应用价值,提高他们对社会责任的认识。
课程性质:本课程为C语言程序设计课程的实践环节,以项目为导向,注重培养学生的动手能力和实际应用能力。
学生特点:学生已经掌握了C语言的基本语法和编程技巧,具有一定的编程基础,但缺乏实际项目经验。
教学要求:结合学生特点和课程性质,采用案例教学、任务驱动等方法,引导学生通过实践掌握课程内容,提高编程能力。
在教学过程中,注重启发式教学,鼓励学生提问、讨论,培养他们的问题解决能力和团队协作精神。
最终达到课程目标,使学生能够独立完成航空订票系统课程设计。
二、教学内容1. C语言基础知识回顾:结构体、数组、函数、指针、文件操作等。
2. 航空订票系统业务流程分析:航班查询、预订、取消预订、显示航班信息等。
3. 数据结构和算法:链表、排序算法、查找算法等在航空订票系统中的应用。
4. 编程规范和调试技巧:代码规范、调试方法、性能优化等。
5. 项目实践:根据业务流程,设计并实现航空订票系统各功能模块。
教学内容安排和进度:1. 第一周:C语言基础知识回顾,重点讲解结构体、数组和函数。
飞机订票系统(C语言代码及流程图)

目录第一部分源程序---------------------------------------------------3第二部分函数流程图--------------------------------------------11 menu()-----------------------------------------------------12 enter()-----------------------------------------------------13 input()-----------------------------------------------------14 browse()---------------------------------------------------15 menu1()---------------------------------------------------16 order()-----------------------------------------------------17 search_time()---------------------------------------------18 search_end()----------------------------------------------19 search()----------------------------------------------------20 book()------------------------------------------------------21 back()------------------------------------------------------22 save()------------------------------------------------------23 load()------------------------------------------------------24 第三部分心得体会------------------------------------------------25第一部分:源程序#include <stdio.h>#include <string.h>#include <stdlib.h>#define N 1000typedef struct plane{char ID[10]; /*航班代号*/char BePlace[10];/*飞机起飞地点*/char EnPlace[10];/*飞机降落终点*/char data[15];/*飞机起飞时间*/int max;/*飞机最大乘客人数*/int price;/*飞机票价*/int num;/*飞机已售票数*/}PLANE;PLANE ti[N];int n;/*当前的航班数目*/void menu();void menu1();void input(int i){printf("请输入航班代号:\n");scanf("%s",ti[i].ID);printf("请输入起飞地点:\n");scanf("%s",ti[i].BePlace);printf("请输入降落地点:\n");scanf("%s",ti[i].EnPlace);printf("请输入起飞时间:\n");scanf("%s",ti[i].data);printf("请输入航班的最大载客人数:\n");scanf("%d",&ti[i].max);printf("请输入航班的票价:\n");scanf("%d",&ti[i].price);ti[i].num=0;}void enter(){int i;system( "cls" );printf("请输入航班的数目(0-%d)?:",N);scanf("%d",&n); /*要输入的记录个数*/printf("\n请输入数据\n\n");for(i=0;i<n;i++){printf("\n请输入第%d 航班记录.\n",i+1);input(i); /*调用输入函数*/}getchar();menu();}void printf_one(int i) /*显示一个记录的函数*/{printf("%11s %6s %10s %6s %6d %6d %6d",ti[i].ID,ti[i].BePlace,ti[i].EnPlace ,ti[i].data,ti[i].price,ti[i].max,ti[i].num);}void browse(){int i;system( "cls" );puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){printf_one(i);printf("\n");}getchar();getchar();menu();}void order() /*排序模块(按平均成绩)*/{int i,j;struct plane s;system( "cls" );for(i=0;i<n;i++) /*冒泡法排序*/{for(j=i+1;j<n;j++)if(strcmp(ti[i].data,ti[j].data)>0){s=ti[i];ti[i]=ti[j];ti[j]=s;}}browse();}void search_time(){int i,m=0;struct plane s;system( "cls" );printf("\n\nEnter the time:");scanf("%s",s.data); /*输入出发的时间*/puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){if(strcmp(s.data,ti[i].data)==0){m++;if((m!=0)&&(m%10==0)) /*目的是分屏显示*/{printf("\n\nPress any key to contiune . . .");getchar();puts("\n\n");}printf_one(i);printf("\n");/*调用显示一个记录的函数*/}}puts("\n--------------------------------------------------------------------");getchar(); /*按任意健*/getchar();menu1();}void serch_end(){int i,m=0;struct plane s;system( "cls" );printf("\n\nEnter the end Place:");scanf("%s",s.EnPlace); /*输入要到达的地方*/puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){if(strcmp(ti[i].EnPlace,s.EnPlace)==0){m++;if((m!=0)&&(m%10==0)) /*目的是分屏显示*/{printf("\n\nPress any key to contiune . . .");getchar();puts("\n\n");}printf_one(i);printf("\n");/*调用显示一个记录的函数*/}}puts("\n--------------------------------------------------------------------");getchar(); /*按任意健*/getchar();menu1();}void menu1(){int n,w1;do{system( "cls" ); /*清屏*/puts("\t\t\t\t 飞机售票操作!\n\n");puts("\t\t*********************MENU*********************\n\n");puts("\t\t\t\t1.按照时间排序");puts("\t\t\t\t2.按照时间查找航班");puts("\t\t\t\t3.按照地点查找航班");puts("\t\t\t\t4.返回主菜单");puts("\n\n\t\t**********************************************\n");printf("Choice your number(1-4): [ ]\b\b");scanf("%d",&n);if(n<1||n>4) /*对选择的数字作判断*/{w1=1;printf("your choice is not between 1 and 4,Please input again:");getchar();getchar();}else w1=0;} while(w1==1);/*选择功能*/switch(n){case 1:order();break;case 2:search_time();break;case 3:serch_end();break;case 4:menu();break;}}int search() /*查找模块*/{int i,k;struct plane s;k=-1;system( "cls" );printf("\n\n请输入要订票的起飞地点:");scanf("%s",s.BePlace); /*输入要到达的地方*/printf("\n\n请输入要订票的降落地点:");scanf("%s",s.EnPlace);printf("\n\n请输入要订票的起飞时间:");scanf("%s",s.data); /*输入出发的时间*/for(i=0;i<n;i++) /*查找要修改的数据*/{if(strcmp(s.BePlace,ti[i].BePlace)==0&&strcmp(s.EnPlace,ti[i].EnPlace)==0&&strcmp(s.dat a,ti[i].data)==0){k=i; /*找到要修改的记录*/printf_one(k);break; /*调用显示一个记录的函数*/}}if(k==-1){printf("\n\nNO exist!");return -1;}elsereturn k;}void book(){int i;system( "cls" );printf("欢迎进入售票窗口!\n");i=search();if(i!=-1){if(ti[i].num>=ti[i].max){printf("\n该趟航班票已售完!");}else{ti[i].num++;printf("\n订票成功!\n");}}elseprintf("该航班不存在!\n");getchar();getchar(); /*按任意健*/menu();}void back(){int i,k=-1;struct plane s;system( "cls" );printf("欢迎进入退票窗口!\n");printf("\n\n输入航班代号:");scanf("%s",s.ID); /*输入要到达的地方*/for(i=0;i<n;i++) /*查找要修改的数据*/{if(strcmp(s.ID,ti[i].ID)==0){k=i; /*找到要修改的记录*/printf_one(k);break; /*调用显示一个记录的函数*/}}if(k==-1){printf("\n\nNO exist!");}else{ti[i].num--;printf("\n退票成功!\n");}getchar(); /*按任意健*/getchar(); /*按任意健*/menu();}void save(){int w=1;FILE *fp;int i;system( "cls" );if((fp=fopen("D:\\我的文档\\桌面\\ticket.txt","wt"))==NULL) /*以输出打开方式,在此前的记录被覆盖*/{printf("\nCannot open file\n");return ;}for(i=0;i<n;i++)if(fwrite(&ti[i],sizeof(struct plane),1,fp)!=1){printf(" error\n");w=0;}if(w==1){printf(" ok!\n");}fclose(fp);getchar();getchar();menu();}void load(){FILE *fp;int i,w;w=1;system( "cls" );if((fp=fopen("D:\\我的文档\\桌面\\ticket.txt","rt"))==NULL){printf("\nCan not open file\n");w=0;return;}n=0;for(i=0;!feof(fp);i++){fread(&ti[i],sizeof(struct plane),1,fp);n++;}n=n-1;fclose(fp);if(w==1)printf("Load !");getchar();getchar();menu();}void menu(){int n,w1;do{system( "cls" ); /*清屏*/ /*清屏*/puts("\t\t\t\t 飞机售票管理系统!\n\n");puts("\t\t*********************MENU*********************\n\n");puts("\t\t\t\t1.输入新航班");puts("\t\t\t\t2.浏览");puts("\t\t\t\t3.航班操作");puts("\t\t\t\t4.订票");puts("\t\t\t\t5.退票");puts("\t\t\t\t6.保存");puts("\t\t\t\t7.载入");puts("\t\t\t\t8.退出");puts("\n\n\t\t**********************************************\n");printf("Choice your number(1-8): [ ]\b\b");scanf("%d",&n);if(n<1||n>8) /*对选择的数字作判断*/{w1=1;printf("your choice is not between 1 and 8,Please input enter to choice again:");getchar();getchar();}else w1=0;} while(w1==1);/*选择功能*/switch(n){case 1:enter();break; /*输入模块*/case 2:browse();break; /*浏览模块*/case 3:menu1();break; /*查找模块*/case 4:book();break; /*订票模块*/case 5:back();break; /*退票模块*/case 6:save();break; /*保存模块*/case 7:load();break; /*加载模块*/case 8:exit(0);}}void main(){menu();}第二部分:函数流程图(2)enter函数流程图第三部分:心得体会(1)开始对c语言只是一种零散的认识,作为一个c语言的初学者对编程没有明确的概念,只是对语句的格式与编程规定有了一个初步了解。
C语言飞机订票系统

#include <stdio.h>#include <string.h>#include <conio.h>#include <ctype.h>#include <stdlib.h>#include <malloc.h>#include <math.h>//overflow#define ok 1typedefstructYidingkehu{//单链表char name[15];//已订票的客户姓名intdingpiaoshu;//已订票数量structYidingkehu *next1;//}Yidingkehu,*Link; typedefstructWeidingkehu{//单链队char name[15];//预订票的客户姓名intyudingpiao;// 要订票数量structWeidingkehu *next2;//下一个链队结点指针}Weidingkehu,*Qptr;typedefstructHangxian{//创建一个含有六个信息的结构体char hangbanhao[15];//航班号-char feijihao[15];//飞机号intfeixingriqi;//起飞时间intchenkerenshu;//座位数intyupiao;//余票char zhongdianzhai[15];//降落城市structHangxian *next;//指向下一个链结点的指针structYidingkehu *yiding;//定义一个指向已订票客户的头结点指针structWeidingkehu *yudingqueue;}Hangxian,*Linklist;LinklistInitLinklist();//01intInsertLinklist(Linklist&head1);//02void hbhchaxun();//通过航班号查询void mddchaxun();//通过目的地查询void lurugongneng();//初始化录入功能void chaxungongnen();//查询功能void dingpiaogongnen();//订票功能void tuipiaogongnen();//退票功能void main(){int n;do{ //打印主界面printf("\t 欢迎使用航空客运订票系统\n");printf("\t+++++++++++++++++++++++++++++\n");printf("\t==>1. 录入功能==\n");printf("\t==>2. 查询功能==\n");printf("\t==>3. 订票功能==\n");printf("\t==>4. 退票功能==\n");printf("\t==>5. 退出==\n");printf("\t+++++++++++++++++++++++++++++\n");printf("\t请选择:");scanf("%d",&n);printf("\n");switch(n){case 1: lurugongneng();//录入功能break;case 2: chaxungongnen();//查询功能break;case 3: dingpiaogongnen();//订票功能break;case 4:tuipiaogongnen();//退票功能break;default :exit(0);//退出}}while(n==1||n==2||n==3||n==4);}void lurugongneng()//初始化的单链表*********************************************************录入功能{Linklist p;//intm,n;if(!p) exit(OVERFLOW);printf("\t请依次输入下面几项内容:\n\n");//这里的输入采用一个个单独输入,避免了乱赋值的现象printf("航班号\n");gets(p->hangbanhao);//这里的二个gets主要是因为在回车键的输入,其中的第一个是来接收上次的回车gets(p->hangbanhao);printf("飞机号\n");gets(p->feijihao);printf("终点站\n");gets(p->zhongdianzhai);printf("飞行日期\n");scanf("%d",&p->feixingriqi);printf("乘客总数\n");scanf("%d",&p->chenkerenshu);printf("余票数\n");scanf("%d",&p->yupiao);}void chaxungongnen()//******************************************************************查询功能{int n;printf("\t 查找航线信息\n");printf("\t+++++++++++++++++++++++++++++\n");printf("\t==>1. 通过目的地查询==\n");printf("\t==>2. 通过航班号查询==\n");printf("\t+++++++++++++++++++++++++++++\n");printf("\t请选择:");scanf("%d",&n);printf("\n");//格式化switch(n){case 1:mddchaxun();break;case 2:hbhchaxun();break;default :break;}void mddchaxun()//通过目的地查询{char c[15];int m;Linklist p=L;printf("\t请输入要查询的目的地:");gets(c);gets(c);//原因同上do{p=p->next;if(p){m=strcmpi((*p).zhongdianzhai,c);//如果==的话则m=0;if(m==0){printf("\t航班信息:\n");printf("\t航班号:%s\n",p->hangbanhao);printf("\t飞机号:%s\n",p->feijihao);printf("\t飞行时间:周%d\n",p->feixingriqi);printf("\t余票量:%d\n",p->yupiao);}}else{//如果不匹配的话就做printf("\t对不起没有你要找的目的地:\n\n"); m=0;}}while(m!=0);}void hbhchaxun()//通过目的地查询char c[15];int m;Linklist p=L;printf("\t请输入要查询的航班号:");gets(c); gets(c);printf("\n");do{p=p->next;if(p){m=strcmpi((*p).hangbanhao,c);//如果==的话则m=0;这里的(*p).与p->的作用是一样的if(m==0){printf("\t航班信息:\n");printf("\t航班号:%s\n",p->hangbanhao);printf("\t飞机号:%s\n",p->feijihao);printf("\t飞行时间:周%d\n",p->feixingriqi);printf("\t余票量:%d\n\n",p->yupiao);}}else{//如果不匹配的话就做printf("\t对不起没有你要找的航班号:\n"); m=0;}}while(m!=0);}void dingpiaogongnen()//***************************************************************订票功能{char c[15];int m=1,piao,ydpiao=0,yd=0,n;//gets(c);printf("请输入终点站名:"); gets(c); printf("\n");p=L->next;if(p) {do{//查找一下,是否有这个航班if(!p){printf("对不起,没有你要找的航班:\n\n");goto loop1;}m=strcmpi(p->zhongdianzhai,c);if(m==0){printf("航班信息:\n");printf("航班号:%s\n",p->hangbanhao);printf("飞机号:%s\n",p->feijihao);printf("飞行时间:周%d\n",p->feixingriqi);printf("余票量:%d\n",p->yupiao);}else p=p->next;}while(m!=0);if(m==0){do{printf("\n请输入你要订的票数:"); scanf("%d",&piao);if(piao<=p->yupiao){h=p->yiding;if(h){h1=h;h=h->next1;h=(structYidingkehu*)malloc(sizeof(Yidingkehu)); printf("请输入你的名字:");gets(h->name);gets(h->name);h->dingpiaoshu=piao;h->next1=h1->next1;h1->next1=h;p->yupiao=p->yupiao-piao;printf("订票成功:\n"); m=2;}}else{printf("余票量:%d\n",p->yupiao);printf("对不起,余票%d 张不足,不能完成订票\n\n",p->yupiao);printf(" 是否要重新订票?\n");printf("需要请输入1 否则请按2 预订请输入3 : ");scanf("%d",&m);printf("\n");if(m==3) goto loop3;}}while(m==1);}}else if(!p){loop3: structWeidingkehu *q3;printf("对不起,该航班的票已售完\n");q.front=p->yudingqueue;if(q.front==q.rear) printf("没有人预订票,是否要预订?\n");else if(q.front!=q.rear) printf("已有人预订票,是否要预订?\n");printf("预订请输入1 否则输入2 : ");scanf("%d",&n);printf("\n");if(n==1){printf("请输入你的姓名"); gets(q3->name); gets(q3->name);//q3不能指向name??? printf("请输入订票数"); scanf("%d",&q3->yudingpiao);q3->next2=NULL;q.rear->next2=q3;q.rear=q3;printf(" 你已经预订了!\n");}}loop1:;}void tuipiaogongnen()//***************************************************************退票功能{}。
C语言编程---火车订票系统源代码

火车订票系统源码(一)#include <conio.h>#include <stdio.h>#include <stdlib.h>#include <string.h>intshoudsave=0 ;int count1=0,count2=0,mark=0,mark1=0 ;/*定义存储火车信息的结构体*/struct train{char num[10];/*列车号*/char city[10];/*目的城市*/char takeoffTime[10];/*发车时间*/char receiveTime[10];/*到达时间*/int price;/*票价*/intbookNum ;/*票数*/};/*订票人的信息*/struct man{charnum[10];/*ID*/char name[10];/*姓名*/intbookNum ;/*需求的票数*/};/*定义火车信息链表的结点结构*/typedefstruct node{struct train data ;struct node * next ;}Node,*Link ;/*定义订票人链表的结点结构*/typedefstruct people{struct man data ;struct people*next ;}bookMan,*bookManLink ;/* 初始界面*/voidprintInterface(){puts("********************************************************"); puts("* Welcome to use the system of booking tickets *");puts("********************************************************"); puts("* You can choose the operation: *");puts("* 1:Insert a train information *");puts("* 2:Inquire a train information *");puts("* 3:Book a train ticket *");puts("* 4:Update the train information *");puts("* 5:Advice to you about the train *");puts("* 6:save information to file *");puts("* 7:quit the system *");puts("********************************************************"); }/*添加一个火车信息*/voidInsertTraininfo(Link linkhead){struct node *p,*r,*s ;charnum[10];r = linkhead ;s = linkhead->next ;while(r->next!=NULL)r=r->next ;while(1){printf("please input the number of the train(0-return)");scanf("%s",num);if(strcmp(num,"0")==0)break ;/*判断是否已经存在*/while(s){if(strcmp(s->data.num,num)==0){printf("the train '%s'has been born!\n",num);return ;}s = s->next ;}p = (struct node*)malloc(sizeof(struct node));strcpy(p->data.num,num);printf("Input the city where the train will reach:");scanf("%s",p->data.city);printf("Input the time which the train take off:");scanf("%s",p->data.takeoffTime);printf("Input the time which the train receive:");scanf("%s",&p->data.receiveTime);printf("Input the price of ticket:");scanf("%d",&p->data.price);printf("Input the number of booked tickets:");scanf("%d",&p->data.bookNum);p->next=NULL ;r->next=p ;r=p ;shoudsave = 1 ;}}/*打印火车票信息*/voidprintTrainInfo(struct node*p){puts("\nThe following is the record you want:");printf(">>number of train: %s\n",p->data.num);printf(">>city the train will reach: %s\n",p->data.city);printf(">>the time the train take off: %s\nthe time the train reach: %s\n",p->data.takeoffTime,p->data.receiveTime);printf(">>the price of the ticket: %d\n",p->data.price);printf(">>the number of booked tickets: %d\n",p->data.bookNum);}struct node * Locate1(Link l,charfindmess[],char numorcity[]){Node*r ;if(strcmp(numorcity,"num")==0){r=l->next ;while(r){if(strcmp(r->data.num,findmess)==0)return r ;r=r->next ;}}else if(strcmp(numorcity,"city")==0){r=l->next ;while(r){if(strcmp(r->data.city,findmess)==0)return r ;r=r->next ;}}return 0 ;}/*查询火车信息*/voidQueryTrain(Link l){Node *p ;intsel ;char str1[5],str2[10];if(!l->next){printf("There is not any record !");return ;}printf("Choose the way:\n>>1:according to the number of train;\n>>2:according to the city:\n");scanf("%d",&sel);if(sel==1){printf("Input the the number of train:");scanf("%s",str1);p=Locate1(l,str1,"num");if(p){printTrainInfo(p);}else{mark1=1 ;printf("\nthe file can't be found!");}}else if(sel==2){printf("Input the city:");scanf("%s",str2);p=Locate1(l,str2,"city");if(p){printTrainInfo(p);}else{mark1=1 ;printf("\nthe file can't be found!");}}}/*订票子模块*/voidBookTicket(Link l,bookManLink k){Node*r[10],*p ;charch,dem ;bookMan*v,*h ;int i=0,t=0 ;charstr[10],str1[10],str2[10];v=k ;while(v->next!=NULL)v=v->next ;printf("Input the city you want to go: ");scanf("%s",&str);p=l->next ;while(p!=NULL){if(strcmp(p->data.city,str)==0){r[i]=p ;i++;}p=p->next ;}printf("\n\nthe number of record have %d\n",i);for(t=0;t<i;t++)printTrainInfo(r[t]);if(i==0)printf("\n\t\t\tSorry!Can't find the train for you!\n"); else{printf("\ndo you want to book it?<1/0>\n");scanf("%d",&ch);if(ch == 1){h=(bookMan*)malloc(sizeof(bookMan)); printf("Input your name: ");scanf("%s",&str1);strcpy(h->,str1);printf("Input your id: ");scanf("%s",&str2);strcpy(h->data.num,str2);printf("Input your bookNum: ");scanf("%d",&dem);h->data.bookNum=dem ;h->next=NULL ;v->next=h ;v=h ;printf("\nLucky!you have booked a ticket!"); getch();shoudsave=1 ;}}}bookMan*Locate2(bookManLinkk,charfindmess[]) {bookMan*r ;r=k->next ;while(r){if(strcmp(r->data.num,findmess)==0){mark=1 ;return r ;}r=r->next ;}return 0 ;}/*修改火车信息*/voidUpdateInfo(Link l){Node*p ;charfindmess[20],ch ;if(!l->next){printf("\nthere isn't record for you to modify!\n"); return ;}else{QueryTrain(l);if(mark1==0){printf("\nDo you want to modify it?\n"); getchar();scanf("%c",&ch);if(ch=='y');{printf("\nInput the number of the train:");scanf("%s",findmess);p=Locate1(l,findmess,"num");if(p){printf("Input new number of train:");scanf("%s",&p->data.num);printf("Input new city the train will reach:");scanf("%s",&p->data.city);printf("Input new time the train take off");scanf("%s",&p->data.takeoffTime);printf("Input new time the train reach:");scanf("%s",&p->data.receiveTime);printf("Input new price of the ticket::");scanf("%d",&p->data.price);printf("Input new number of people who have booked ticket:"); scanf("%d",&p->data.bookNum);printf("\nmodifying record is sucessful!\n");shoudsave=1 ;}elseprintf("\t\t\tcan't find the record!");}}elsemark1=0 ;}}/*系统给用户的提示信息*/voidAdvicedTrains(Link l){Node*r ;charstr[10];int mar=0 ;r=l->next ;printf("Iuput the city you want to go: ");scanf("%s",str);while(r){if(strcmp(r->data.city,str)==0&&r->data.bookNum<200){mar=1 ;printf("\nyou can select the following train!\n");printf("\n\nplease select the fourth operation to book the ticket!\n"); printTrainInfo(r);}r=r->next ;}if(mar==0)printf("\n\t\t\tyou can't book any ticket now!\n");}/*保存火车信息*/voidSaveTrainInfo(Link l){FILE*fp ;Node*p ;int count=0,flag=1 ;fp=fopen("c:\\train.txt","wb");if(fp==NULL){printf("the file can't be opened!");return ;}p=l->next ;while(p){if(fwrite(p,sizeof(Node),1,fp)==1){p=p->next ;count++;}else{flag=0 ;break ;}}if(flag){printf("the number of the record which have been saved is %d\n",count); shoudsave=0 ;}fclose(fp);}/*保存订票人的信息*/voidSaveBookmanInfo(bookManLink k){FILE*fp ;bookMan*p ;int count=0,flag=1 ;fp=fopen("c:\\man.txt","wb");if(fp==NULL){printf("the file can't be opened!");return ;}p=k->next ;while(p){if(fwrite(p,sizeof(bookMan),1,fp)==1){p=p->next ;count++;}else{flag=0 ;break ;}}if(flag){printf("the number of the record which have been saved is %d\n",count); shoudsave=0 ;}fclose(fp);}int main(){FILE*fp1,*fp2 ;Node*p,*r ;char ch1,ch2 ;Link l ;bookManLink k ;bookMan*t,*h ;intsel ;l=(Node*)malloc(sizeof(Node));l->next=NULL ;r=l ;k=(bookMan*)malloc(sizeof(bookMan));k->next=NULL ;h=k ;fp1=fopen("c:\\train.txt","ab+");if((fp1==NULL)){printf("can't open the file!");return 0 ;}while(!feof(fp1)){p=(Node*)malloc(sizeof(Node));if(fread(p,sizeof(Node),1,fp1)==1){p->next=NULL ;r->next=p ;r=p ;count1++;}}fclose(fp1);fp2=fopen("c:\\man.txt","ab+");if((fp2==NULL)){printf("can't open the file!");return 0 ;}while(!feof(fp2)){t=(bookMan*)malloc(sizeof(bookMan)); if(fread(t,sizeof(bookMan),1,fp2)==1){t->next=NULL ;h->next=t ;h=t ;count2++;}}fclose(fp2);while(1){system("cls");printInterface();printf("please choose the operation: "); scanf("%d",&sel);system("cls");if(sel==8){if(shoudsave==1){getchar();printf("\nthe file have been changed!do you want to save it(y/n)?\n"); scanf("%c",&ch1);if(ch1=='y'||ch1=='Y'){SaveBookmanInfo(k);SaveTrainInfo(l);}}printf("\nThank you!!You are welcome too\n");break ;}switch(sel){case 1 :InsertTraininfo(l);break ;case 2 :QueryTrain(l);break ;case 3 :BookTicket(l,k);break ;case 4 :UpdateInfo(l);break ;case 5 :AdvicedTrains(l);break ;case 6 :SaveTrainInfo(l);SaveBookmanInfo(k);break ;case 7 :return 0;}printf("\nplease press any key to continue.......");getch();}return 0;}11/11。
C语言课程设计——电影院订票系统

C语⾔课程设计——电影院订票系统1. 课题简介⼤家都爱看电影,现请参考⼀个熟悉电影票预订系统,实现C语⾔版的订票系统。
了解订票如何实现的。
系统主要有2类⽤户:管理员⽤户和顾客⽤户。
管理员⽤户登录系统后,实现电影放映厅信息管理和电影场次信息管理。
具体菜单有:1.电影放映厅信息管理选择该菜单能展⽰所有放映厅,⽤户输⼊某个放映厅编号后,能实现对放映厅增加、删除、修改功能。
主要对movie_house.txt数据修改。
放映厅主要字段信息有:放映厅编号、放映厅名称、放映厅⾏数、放映厅列数、放映厅座位初始状态。
假如放映厅是⼀个10⾏10列座位安排,其初始状态可以⽣成⼀个⼆维数组house[10][10]={0,1,2,0,0},存储座位状态。
0表⽰未定、1表⽰已定、2表⽰不能定。
初始时候应该只有0,2两种状态。
2.电影场次信息管理实现对movie.txt数据增删改及查找。
答辩务必演⽰增删改操作,对于已存在场次能提⽰不得修改。
不存在场次不能删除等容错处理。
修改和添加记录时候,⼀个放映厅⼀个时段只能排1部电影。
若超过要提⽰不能修改。
movie.txt主要字段有:电影场次编号、电影名称、播放⽇期、播放时间段、所在放映厅、放映厅座位当前状态。
(1)放映厅位置当前状态,表⽰当前位置购票情况,如house[10][10]={0,1,2,0,0}。
其中:0表⽰未定座位、1表⽰已定座位、2表⽰不能定座位。
(2)当前状态初始值应该是从movie_house.txt读取放映厅座位初始状态。
顾客登录系统后,主菜单:查看我的订单展⽰所有历史订票信息,然后可删除未看的电影订单。
(选做)注意删除订单后,相应电影场次中位置信息状态也要修改。
电影订票操作步骤如下:(1) 展⽰当前时间段后可看的电影场次信息。
(注意时间,⼀定是当前时间段后的电影信息)(2) 顾客输⼊观看电影名称和时间段,展⽰⽬前厅内位置信息。
注意⽤矩阵⽅式显⽰位置信息,每⾏10列左右,具体⾃⼰设计。
飞机订票系统c语言课程设计

飞机订票系统 c语言课程设计一、教学目标本课程的学习目标主要包括知识目标、技能目标和情感态度价值观目标。
知识目标要求学生掌握飞机订票系统的功能、结构及其相关原理;技能目标要求学生能够运用C语言独立完成飞机订票系统的开发;情感态度价值观目标要求学生培养团队协作意识,增强对计算机编程的兴趣。
通过对课程性质、学生特点和教学要求的分析,我们将目标分解为具体的学习成果。
首先,学生需要理解飞机订票系统的业务流程,掌握C语言的基本语法和编程技巧;其次,学生能够运用所学的知识独立完成飞机订票系统的开发,提高实际操作能力;最后,学生在团队协作过程中培养沟通与协作能力,增强对计算机编程的兴趣和自信心。
二、教学内容本课程的教学内容主要包括飞机订票系统的功能介绍、C语言基础知识、飞机订票系统的模块划分和编程实现。
首先,介绍飞机订票系统的功能,包括用户注册、登录、航班查询、机票预订、支付结算等模块。
其次,讲解C语言的基本语法、数据类型、运算符、控制结构等基础知识。
接着,对飞机订票系统进行模块划分,引导学生了解各模块之间的关系和功能实现。
最后,分别针对各个模块,引导学生运用C语言进行编程实现,完成飞机订票系统的开发。
三、教学方法为了激发学生的学习兴趣和主动性,本课程将采用多种教学方法。
包括讲授法、讨论法、案例分析法和实验法等。
首先,通过讲授法向学生传授飞机订票系统的相关知识和C语言的基本语法。
其次,采用讨论法引导学生针对飞机订票系统的功能和模块划分进行深入探讨,提高团队协作能力。
然后,运用案例分析法分析实际开发过程中遇到的问题,培养学生解决问题的能力。
最后,通过实验法让学生动手实践,独立完成飞机订票系统的开发,提高实际操作能力。
四、教学资源本课程所需的教学资源包括教材、参考书、多媒体资料和实验设备。
教材方面,我们将选用《C语言程序设计》作为主教材,辅以《飞机订票系统设计与实现》等相关参考书。
多媒体资料包括教学PPT、视频教程等,以丰富教学手段,提高学生的学习兴趣。
c语言课程设计影院订票系统

c语言课程设计影院订票系统一、教学目标本节课的教学目标是使学生掌握C语言编程的基本语法,能够运用C语言设计简单的影院订票系统。
具体来说,知识目标包括掌握C语言的数据类型、变量、运算符、控制结构等基本概念;技能目标包括能够使用C语言编写简单的程序,并进行调试和优化;情感态度价值观目标包括培养学生的编程兴趣,提高学生解决问题的能力,培养学生的团队合作意识。
二、教学内容本节课的教学内容主要包括C语言的基本语法和编程方法。
具体来说,教学大纲如下:1.介绍C语言的基本概念,包括数据类型、变量、运算符等。
2.讲解C语言的控制结构,包括条件语句、循环语句等。
3.介绍函数的定义和调用,以及函数的参数传递和返回值。
4.通过设计影院订票系统的实例,使学生掌握C语言编程的基本方法。
三、教学方法为了提高学生的学习兴趣和主动性,本节课将采用多种教学方法。
具体来说,将采用以下教学方法:1.讲授法:讲解C语言的基本语法和编程方法。
2.案例分析法:通过设计影院订票系统的实例,使学生掌握C语言编程的基本方法。
3.实验法:让学生亲自动手编写程序,进行调试和优化,提高学生的实际操作能力。
四、教学资源为了支持教学内容和教学方法的实施,丰富学生的学习体验,我们将准备以下教学资源:1.教材:选用权威、实用的C语言教材,为学生提供系统的学习资料。
2.参考书:提供丰富的参考书籍,帮助学生深入理解C语言编程。
3.多媒体资料:制作精美的PPT,生动形象地展示C语言编程的基本概念和实例。
4.实验设备:准备计算机实验室,让学生在实验过程中亲自编写程序,提高实际操作能力。
五、教学评估本节课的教学评估将采取多元化的评估方式,以全面、客观、公正地评价学生的学习成果。
具体评估方式如下:1.平时表现:通过观察学生在课堂上的参与程度、提问回答、小组讨论等表现,评估学生的学习态度和理解程度。
2.作业:布置相关的编程作业,评估学生对C语言编程的掌握程度,以及学生的编程能力和解决问题的能力。
c语言课程设计-汽车售票系统

case 3:Show();return;
case 4:SaveTxt();return;
case 5:History();return;
case 6:About();return;
case 0:exit(0);return;
}
void BuyTick()
{
//得到当前时间
t=time(0);
date=localtime(&t);
printf("当前时间 %02d:%02d\n\n",date->tm_hour,date->tm_min);
printf("您可以购买以下车次票:\n");
printf(" %2d\t %02d:%02d%10d%10d\n",i+1,bus[i].hour,bus[i].min,bus[i].max,bus[i].seat);
j++;
sign[i]=i;
}
printf("━━━━━━━━━━━━━━━━━━━\n");
itoa(a,filename,10);strcat(filename,"-");
itoa(b,temp,10);strcat(filename,temp);strcat(filename,"-");
itoa(c,temp,10);strcat(filename,temp);
//开始写入数据
fp=fopen(filename,"w");
for(int i=0;i<5;i++)
c语言飞机订票系统课程设计

c 语言飞机订票系统课程设计一、课程目标知识目标:1. 学生理解C语言中结构体、数组、函数等基本概念,并能运用这些知识设计飞机订票系统。
2. 学生掌握C语言文件操作,实现对飞机票数据的存储和读取。
3. 学生了解C语言中字符串处理函数,并能够运用字符串操作进行信息输入和输出。
技能目标:1. 学生能够运用结构体和数组创建和管理飞机票数据,实现票务信息的增删改查功能。
2. 学生能够编写C语言程序,实现用户界面交互,包括用户登录、航班查询、购票、退票等功能。
3. 学生能够利用文件操作保存和加载飞机订票系统数据,保证数据的持久性。
情感态度价值观目标:1. 学生培养编程的兴趣,激发学习C语言的积极性,形成自主学习的习惯。
2. 学生通过合作完成课程设计,培养团队协作能力和沟通能力,增强集体荣誉感。
3. 学生了解飞机订票系统的实际应用,认识到编程知识在解决实际问题中的价值,增强学以致用的意识。
课程性质:本课程设计为实践性课程,旨在让学生将所学的C语言知识应用于实际项目中,提高编程能力和解决实际问题的能力。
学生特点:学生已具备C语言基础知识,具有一定的编程能力,但对实际项目的开发尚缺乏经验。
教学要求:教师需引导学生复习相关知识点,提供必要的技术支持,鼓励学生自主探究和团队协作,注重培养学生的实践能力和创新能力。
在教学过程中,关注学生的个体差异,给予个性化指导,确保每位学生都能在课程中取得进步。
通过课程设计,使学生将理论知识与实践相结合,提高综合运用C语言知识解决实际问题的能力。
二、教学内容1. 复习C语言基础知识:结构体、数组、函数、指针、文件操作、字符串处理函数等。
相关教材章节:第一章至第六章- 结构体与数组:理解结构体的定义和用法,掌握结构体数组的操作。
- 函数:掌握函数的定义、调用和参数传递。
- 指针:理解指针的概念和操作,掌握指针在数组、函数中的应用。
- 文件操作:掌握文件的打开、读写、关闭操作。
- 字符串处理函数:熟悉常用的字符串处理函数,如strcpy、strcat等。
c语言火车售票系统课程设计

c语言火车售票系统课程设计一、课程目标知识目标:1. 理解C语言中数组、函数、指针、结构体等基本概念,并能运用到火车售票系统的设计与实现中;2. 掌握C语言文件操作,实现火车票信息的存储与读取;3. 理解并掌握C语言中模块化编程思想,将火车售票系统划分为多个功能模块。
技能目标:1. 能够运用C语言编写出具有良好结构和可读性的代码;2. 培养学生分析问题、解决问题的能力,通过设计火车售票系统,学会使用C 语言进行实际项目开发;3. 学会使用调试工具,对火车售票系统进行测试和优化。
情感态度价值观目标:1. 培养学生合作意识,学会在团队中共同解决问题,提高沟通与协作能力;2. 激发学生对计算机编程的兴趣,培养勇于探索、积极创新的精神;3. 培养学生关注社会实际问题的责任感,了解信息技术在实际应用中的作用和价值。
课程性质:本课程为C语言程序设计课程的实践环节,通过设计火车售票系统,让学生将所学理论知识运用到实际项目中。
学生特点:学生已具备C语言基础知识和一定的编程能力,但对实际项目的开发流程和模块化编程思想尚不熟悉。
教学要求:注重理论与实践相结合,引导学生自主探究,培养学生实际编程能力和团队协作能力。
在教学过程中,关注学生的个体差异,提供个性化指导,确保每位学生都能达到课程目标。
通过课程学习,使学生具备独立开发小型项目的能力。
二、教学内容1. 火车售票系统需求分析:介绍项目背景,分析系统功能需求,明确学生需要实现的功能模块,如用户登录、车次查询、购票、退票、余票显示等。
2. C语言基础知识回顾:- 数组:回顾一维数组、二维数组的概念和应用;- 函数:介绍函数定义、调用、参数传递等基本概念;- 指针:讲解指针的定义、使用和指针操作;- 结构体:回顾结构体的定义和使用。
3. 火车售票系统设计:- 系统架构设计:引导学生采用模块化设计思想,将系统划分为多个功能模块;- 数据结构设计:介绍如何使用结构体和数组来存储和管理车次、座位、用户等信息。
火车票售票系统c语言设计

火车票售票系统的设计可以使用C语言来实现。
下面是一个简单的示例,展示了如何设计一个基本的火车票售票系统:```c#include <stdio.h>#include <stdlib.h>#define MAX_SEATS 100typedef struct {int seat_number;char passenger_name[50];} Ticket;Ticket tickets[MAX_SEATS];int total_tickets = 0;void displayMenu() {printf("\n=== 火车票售票系统 ===\n");printf("1. 购买票\n");printf("2. 查询票\n");printf("3. 取消票\n");printf("4. 退出\n");printf("=====================\n");printf("请输入选项: ");}void buyTicket() {if (total_tickets >= MAX_SEATS) {printf("对不起,票已售完。
\n");return;}Ticket ticket;printf("请输入座位号: ");scanf("%d", &ticket.seat_number);// 检查座位号是否已经被购买for (int i = 0; i < total_tickets; i++) {if (tickets[i].seat_number == ticket.seat_number) {printf("对不起,该座位已被购买。
\n");return;}}printf("请输入乘客姓名: ");scanf("%s", ticket.passenger_name);tickets[total_tickets++] = ticket;printf("购票成功!\n");}void queryTicket() {int seat_number;printf("请输入座位号: ");scanf("%d", &seat_number);for (int i = 0; i < total_tickets; i++) {if (tickets[i].seat_number == seat_number) {printf("座位号: %d\n", tickets[i].seat_number);printf("乘客姓名: %s\n", tickets[i].passenger_name); return;}}printf("对不起,该座位未被购买。
c语言课程设计--飞机订票系统

c语言课程设计–飞机订票系统一、教学目标本课程的教学目标是使学生掌握C语言编程的基本知识,能够使用C语言设计并实现一个简单的飞机订票系统。
具体分为以下三个部分:1.知识目标:学生需要掌握C语言的基本语法、数据类型、运算符、控制结构、函数等编程基础。
2.技能目标:学生能够运用C语言进行程序设计,解决实际问题,如设计飞机订票系统的各个功能模块。
3.情感态度价值观目标:培养学生对计算机科学的兴趣,提高学生解决问题的能力,培养学生的团队合作精神。
二、教学内容教学内容主要包括C语言的基本语法、数据类型、运算符、控制结构、函数等编程基础,以及如何使用C语言设计并实现一个简单的飞机订票系统。
具体安排如下:1.C语言基本语法和数据类型2.C语言运算符和控制结构3.C语言函数和数组4.C语言指针和字符串5.飞机订票系统的设计和实现三、教学方法为了达到课程目标,我们将采用以下教学方法:1.讲授法:用于讲解C语言的基本语法、数据类型、运算符、控制结构、函数等编程基础。
2.案例分析法:通过分析实际案例,让学生了解如何使用C语言设计并实现飞机订票系统。
3.实验法:让学生动手编写代码,实现飞机订票系统的各个功能模块。
四、教学资源为了支持教学内容和教学方法的实施,我们将准备以下教学资源:1.教材:《C程序设计语言》或《C语言程序设计》2.参考书:《C Primer Plus》或《C和指针》3.多媒体资料:教学PPT、视频教程4.实验设备:计算机、网络环境五、教学评估为了全面、客观地评估学生的学习成果,我们将采用以下评估方式:1.平时表现:通过课堂参与、提问、小组讨论等环节,评估学生的学习态度和积极性。
2.作业:布置课后编程作业,评估学生对C语言知识的掌握程度及编程能力。
3.考试:期末进行闭卷考试,评估学生对C语言编程基础知识的掌握情况。
4.项目实践:要求学生分组设计并实现一个简单的飞机订票系统,评估学生的实际编程能力和团队协作能力。
飞机订票系统(C语言代码及流程图)

目录第一部分源程序---------------------------------------------------3第二部分函数流程图--------------------------------------------11 menu()-----------------------------------------------------12 enter()-----------------------------------------------------13 input()-----------------------------------------------------14 browse()---------------------------------------------------15 menu1()---------------------------------------------------16 order()-----------------------------------------------------17 search_time()---------------------------------------------18 search_end()----------------------------------------------19 search()----------------------------------------------------20 book()------------------------------------------------------21 back()------------------------------------------------------22 save()------------------------------------------------------23 load()------------------------------------------------------24 第三部分心得体会------------------------------------------------25第一部分:源程序#include <stdio.h>#include <string.h>#include <stdlib.h>#define N 1000typedef struct plane{char ID[10]; /*航班代号*/char BePlace[10];/*飞机起飞地点*/char EnPlace[10];/*飞机降落终点*/char data[15];/*飞机起飞时间*/int max;/*飞机最大乘客人数*/int price;/*飞机票价*/int num;/*飞机已售票数*/}PLANE;PLANE ti[N];int n;/*当前的航班数目*/void menu();void menu1();void input(int i){printf("请输入航班代号:\n");scanf("%s",ti[i].ID);printf("请输入起飞地点:\n");scanf("%s",ti[i].BePlace);printf("请输入降落地点:\n");scanf("%s",ti[i].EnPlace);printf("请输入起飞时间:\n");scanf("%s",ti[i].data);printf("请输入航班的最大载客人数:\n");scanf("%d",&ti[i].max);printf("请输入航班的票价:\n");scanf("%d",&ti[i].price);ti[i].num=0;}void enter(){int i;system( "cls" );printf("请输入航班的数目(0-%d)?:",N);scanf("%d",&n); /*要输入的记录个数*/printf("\n请输入数据\n\n");for(i=0;i<n;i++){printf("\n请输入第%d 航班记录.\n",i+1);input(i); /*调用输入函数*/}getchar();menu();}void printf_one(int i) /*显示一个记录的函数*/{printf("%11s %6s %10s %6s %6d %6d %6d",ti[i].ID,ti[i].BePlace,ti[i].EnPlace ,ti[i].data,ti[i].price,ti[i].max,ti[i].num);}void browse(){int i;system( "cls" );puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){printf_one(i);printf("\n");}getchar();getchar();menu();}void order() /*排序模块(按平均成绩)*/{int i,j;struct plane s;system( "cls" );for(i=0;i<n;i++) /*冒泡法排序*/{for(j=i+1;j<n;j++)if(strcmp(ti[i].data,ti[j].data)>0){s=ti[i];ti[i]=ti[j];ti[j]=s;}}browse();}void search_time(){int i,m=0;struct plane s;system( "cls" );printf("\n\nEnter the time:");scanf("%s",s.data); /*输入出发的时间*/puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){if(strcmp(s.data,ti[i].data)==0){m++;if((m!=0)&&(m%10==0)) /*目的是分屏显示*/{printf("\n\nPress any key to contiune . . .");getchar();puts("\n\n");}printf_one(i);printf("\n");/*调用显示一个记录的函数*/}}puts("\n--------------------------------------------------------------------");getchar(); /*按任意健*/getchar();menu1();}void serch_end(){int i,m=0;struct plane s;system( "cls" );printf("\n\nEnter the end Place:");scanf("%s",s.EnPlace); /*输入要到达的地方*/puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){if(strcmp(ti[i].EnPlace,s.EnPlace)==0){m++;if((m!=0)&&(m%10==0)) /*目的是分屏显示*/{printf("\n\nPress any key to contiune . . .");getchar();puts("\n\n");}printf_one(i);printf("\n");/*调用显示一个记录的函数*/}}puts("\n--------------------------------------------------------------------");getchar(); /*按任意健*/getchar();menu1();}void menu1(){int n,w1;do{system( "cls" ); /*清屏*/puts("\t\t\t\t 飞机售票操作!\n\n");puts("\t\t*********************MENU*********************\n\n");puts("\t\t\t\t1.按照时间排序");puts("\t\t\t\t2.按照时间查找航班");puts("\t\t\t\t3.按照地点查找航班");puts("\t\t\t\t4.返回主菜单");puts("\n\n\t\t**********************************************\n");printf("Choice your number(1-4): [ ]\b\b");scanf("%d",&n);if(n<1||n>4) /*对选择的数字作判断*/{w1=1;printf("your choice is not between 1 and 4,Please input again:");getchar();getchar();}else w1=0;} while(w1==1);/*选择功能*/switch(n){case 1:order();break;case 2:search_time();break;case 3:serch_end();break;case 4:menu();break;}}int search() /*查找模块*/{int i,k;struct plane s;k=-1;system( "cls" );printf("\n\n请输入要订票的起飞地点:");scanf("%s",s.BePlace); /*输入要到达的地方*/printf("\n\n请输入要订票的降落地点:");scanf("%s",s.EnPlace);printf("\n\n请输入要订票的起飞时间:");scanf("%s",s.data); /*输入出发的时间*/for(i=0;i<n;i++) /*查找要修改的数据*/{if(strcmp(s.BePlace,ti[i].BePlace)==0&&strcmp(s.EnPlace,ti[i].EnPlace)==0&&strcmp(s.dat a,ti[i].data)==0){k=i; /*找到要修改的记录*/printf_one(k);break; /*调用显示一个记录的函数*/}}if(k==-1){printf("\n\nNO exist!");return -1;}elsereturn k;}void book(){int i;system( "cls" );printf("欢迎进入售票窗口!\n");i=search();if(i!=-1){if(ti[i].num>=ti[i].max){printf("\n该趟航班票已售完!");}else{ti[i].num++;printf("\n订票成功!\n");}}elseprintf("该航班不存在!\n");getchar();getchar(); /*按任意健*/menu();}void back(){int i,k=-1;struct plane s;system( "cls" );printf("欢迎进入退票窗口!\n");printf("\n\n输入航班代号:");scanf("%s",s.ID); /*输入要到达的地方*/for(i=0;i<n;i++) /*查找要修改的数据*/{if(strcmp(s.ID,ti[i].ID)==0){k=i; /*找到要修改的记录*/printf_one(k);break; /*调用显示一个记录的函数*/}}if(k==-1){printf("\n\nNO exist!");}else{ti[i].num--;printf("\n退票成功!\n");}getchar(); /*按任意健*/getchar(); /*按任意健*/menu();}void save(){int w=1;FILE *fp;int i;system( "cls" );if((fp=fopen("D:\\我的文档\\桌面\\ticket.txt","wt"))==NULL) /*以输出打开方式,在此前的记录被覆盖*/{printf("\nCannot open file\n");return ;}for(i=0;i<n;i++)if(fwrite(&ti[i],sizeof(struct plane),1,fp)!=1){printf("file write error\n");w=0;}if(w==1){printf("file save ok!\n");}fclose(fp);getchar();getchar();menu();}void load(){FILE *fp;int i,w;w=1;system( "cls" );if((fp=fopen("D:\\我的文档\\桌面\\ticket.txt","rt"))==NULL){printf("\nCan not open file\n");w=0;return;}n=0;for(i=0;!feof(fp);i++){fread(&ti[i],sizeof(struct plane),1,fp);n++;}n=n-1;fclose(fp);if(w==1)printf("Load file ok!");getchar();getchar();menu();}void menu(){int n,w1;do{system( "cls" ); /*清屏*/ /*清屏*/puts("\t\t\t\t 飞机售票管理系统!\n\n");puts("\t\t*********************MENU*********************\n\n");puts("\t\t\t\t1.输入新航班");puts("\t\t\t\t2.浏览");puts("\t\t\t\t3.航班操作");puts("\t\t\t\t4.订票");puts("\t\t\t\t5.退票");puts("\t\t\t\t6.保存");puts("\t\t\t\t7.载入");puts("\t\t\t\t8.退出");puts("\n\n\t\t**********************************************\n");printf("Choice your number(1-8): [ ]\b\b");scanf("%d",&n);if(n<1||n>8) /*对选择的数字作判断*/{w1=1;printf("your choice is not between 1 and 8,Please input enter to choice again:");getchar();getchar();}else w1=0;} while(w1==1);/*选择功能*/switch(n){case 1:enter();break; /*输入模块*/case 2:browse();break; /*浏览模块*/case 3:menu1();break; /*查找模块*/case 4:book();break; /*订票模块*/case 5:back();break; /*退票模块*/case 6:save();break; /*保存模块*/case 7:load();break; /*加载模块*/case 8:exit(0);}}void main(){menu();}第二部分:函数流程图(2)enter函数流程图第三部分:心得体会(1)开始对c语言只是一种零散的认识,作为一个c语言的初学者对编程没有明确的概念,只是对语句的格式与编程规定有了一个初步了解。
C语言火车票管理系统

#include<stdio.h>#include<string.h>#include<stdlib.h>#include<time.h>#include<conio.h>#define N 1000typedef struct TICKET //定义新结构体TICKET {char num[10]; //车次char hour[3];char min[3];char from[10];char to[10];float hours;int max; //车载容量int now; //已售票数}CLASS;int class_num=0;CLASS records[N];int system_time();void message();void ShowTable1();void ShowTable2(int i);void Display();void add();void save();void load(); // 按班次查询void search(); //查询void change(); //修改void quit(); //退出void buyticket(); //售票void deleteticket(); //取消int menu_select(); //菜单int whether(int); //判断购买时间void find(char s1[],char s2[]); //按起点终点查询void deletemessage(); //删除int findnum(char s1[]); //班次查询void get(int,int); //修改及增加班次char*menu[]={" 欢迎使用车票查询系统","\n*******************菜单***********************", "\n 1. 录入班次","\n 2. 浏览班次信息","\n 3. 查询路线","\n 4. 增加班次","\n 5. 售票","\n 6. 退票","\n 7. 修改班次","\n 8. 删除班次","\n 9. 退出"};int main(){system("cls");while(1){switch(menu_select()) //菜单{case 1: message();break;case 2: Display();break;case 3: search();break;case 4: add();break;case 5: buyticket();break;case 6: deleteticket();break;case 7: change();break;case 8: deletemessage();break;case 9: quit();break;}}}int menu_select() //菜单{char s[5];int c,i;system("cls");for(i=0;i<11;i++){printf("%s",menu[i]); //输出菜单}i=0;while(c<0||c>9){printf("\n");printf("\n请输入选项(1-9): ");scanf("%s",s);c=atoi(s);}//输出菜单return c;}void message() //录入{int i=0,j=5,h;char s[5];FILE *fp; //定义文件型指针变量system("cls"); //刷屏if((fp=fopen("d:车票管理系统0.dat","rb"))!=NULL) //fopen打开文件{printf("增加信息\n");printf("请输入任意键返回\n");scanf("%s",s);i=1;}if(i==0){system("cls"); //刷屏printf("请输入班次总数:\n");scanf("%d",&class_num); //指向班次指针system("cls"); //刷屏for(i=0;i<class_num;i++){system("cls"); //刷屏printf("请输入%d班次信息:\n",i+1);h=-1;for(;h!=i;) ///循环输出{printf("请输入班次:\n");scanf("%s",records[i].num);for(h=0;h<i;h++)if(strcmp(records[h].num,records[i].num)==0){printf("该班次已存在\n");break;}}get(i,j); //修改及增加班次j=5;}save(); //调用保存函数}}/*******************************显示所有函数********************************/void Display() //显示所有函数{int i,j;system("cls"); //刷屏load(); // 按班次查询ShowTable1();for(i=0,j=0;i<class_num;i++,j+=2) //按班次顺序输出{if(whether(i)) //判断时间是否超出printf("|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|",records[i].num,records[i].h our,records[i].min, records[i].from,records[i].to,records[i].hours,records[i].max,records[i].now);elseprintf("|%10s| 已发车|%10s|%10s|%8.1f|%8d|%8d|",records[i].num,records[i].from,records[i].to,records[i].hours,records[i].max,records[i].now);}ShowTable2(j);printf("\n按任意键继续\n");getch();}void ShowTable1(){int i=2;system("cls"); //刷屏printf(" 班次信息\n");printf("\n|----------|----------|----------|----------|--------|--------|--------|\n");printf("\n| 班次| 发车时间| 起点站| 终点站|行车时间|额定载量| 已售票|\n");}void ShowTable2(int i){printf("\n|----------|----------|----------|----------|--------|--------|--------|\n");}void search() //查询班次{int i;char s1[10]={'\0'},s2[10]={'\0'};system("cls"); //刷屏printf("1. 按班次查询\n");printf("2. 按终点站查询\n");printf("3. 退出\n");printf("请选择(1-3):\n");scanf("%d",&i);load(); //按班次查询switch(i){case 1: printf("请输入要查询的班次:\n");scanf("%s",s1);find(s1,s2);break;case 2: printf("请输入要查询终点站:\n");scanf("%s",s2);find(s1,s2);break;case 3: break;default : printf("输入错误!\n");break;}printf("按任意键继续\n");getch();}void find(char s1[],char s2[]){int i,h=0,m;ShowTable1();if(s2[0]=='\0')m=1;else m=0;for(i=0;i<class_num;i++)if(strcmp(s1,records[i].num)==0||strcmp(s2,records[i].to)==0){printf("\n");printf("|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|",records[i].num,records[i].h our,records[i].min,records[i].from,records[i].to,records[i].hours,records[i].max,records[i].now);h+=2;if(m==1)break;}ShowTable2(h);if(h==0)printf("查找的班次不存在\n");}void add(){int i,j=5;load();system("cls");printf("1. 增加班次\n");printf("2. 返回\n");printf("请选择(1-2)\n");scanf("%d",&i);if(i==1){system("cls");printf("1. 输入要增加的班次:\n");scanf("%s",records[class_num].num);for(i=0;i<class_num;i++)if(strcmp(records[class_num].num,records[i].num)==0){printf("输入错误\n");getch();break;}if(i==class_num){get(i,j);class_num++;save();}}}void buyticket(){int i;char num[10];system("cls");printf("1. 售票\n");printf("2. 返回\n");printf("请选择(1-2):\n");scanf("%d",&i);if(i==1){load(); // 按班次查询search();printf("请输入要订票的班次(若无请输入0):\n");scanf("%s",num);for(i=0;i<class_num;i++)if(strcmp(num,records[i].num)==0)if(records[i].max>records[i].now&&whether(i)==1){records[i].now++;printf("通向%s班次为%s的票订票成功\n",records[i].to,records[i].num);save();getch();break;}else{printf("该班次已满或已发出!\n");getch();}}}void deleteticket(){int i;char num[10];system("cls");printf("1. 退票\n");printf("2. 返回\n");printf("请选择(1-2)\n:");scanf("%d",&i);if(i==1){system("cls");load();printf("请输入要退票的班次:\n");scanf("%s",num);i=findnum(num);if(strcmp(num,records[i].num)==0)if(whether(i)){printf("是否确认");scanf("%s",num);if(num[0]=='y'||num[0]=='Y'){records[i].now--;printf("退票成功\n");save();getch();}}else{printf("该班车已发出,无法退票\n");getch();}if(i==class_num){printf("输入错误\n");getch();}}}void change(){char num[10],s[10];int h=0,j=13,i;load();system("cls");printf("请输入要修改的班次:\n");scanf("%s",num);i=findnum(num);if(i==class_num){printf("输入错误\n");getch();}else{printf("确认修改\n");scanf("%s",s);if(s[0]=='y'||s[0]=='Y'){get(i,j);save();}}}void deletemessage(){int i,h=0;char num[10];system("cls");printf("1. 删除班次\n");printf("2. 返回\n");printf("请选择(1-2):\n");scanf("%d",&i);if(i==1){system("cls");printf("请输入要删除的班次:\n");scanf("%s",num);i=findnum(num);if(i==class_num){printf("输入错误\n");getch();}else{printf("是否确认\n");scanf("%s",num);if(num[0]=='y'||num[0]=='Y'){for(;i<class_num-1;i++)records[i]=records[i+1];class_num--;save();printf("删除成功\n");getch();}}}}int findnum(char s1[]){int i,h=0;ShowTable1();for(i=0;i<class_num;i++){if(strcmp(s1,records[i].num)==0){printf("|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|",records[i].num,records[i].h our,records[i].min,records[i].from,records[i].to,records[i].hours,records[i].max,records[i] .now);h+=2;break;}}ShowTable2(h);return i;}void save(){FILE *fp1,*fp2;if((fp1=fopen("d:车票管理系统.dat","wb"))==NULL) //打开文件{printf("文件打开错误!\n");exit(0);}if((fp2=fopen("d:车票管理系统0.dat","wb"))==NULL){printf("文件打开错误!\n");exit(0);}fwrite(&class_num,sizeof(int),1,fp2);fwrite(records,sizeof(CLASS),class_num,fp1);fclose(fp1);fclose(fp2);}void load(){FILE *fp1,*fp2;if((fp1=fopen("d:车票管理系统.dat","rb"))==NULL){system("cls");printf("文件打开错误\n");getch();exit(0);}if((fp2=fopen("d:车票管理系统0.dat","rb"))==NULL) {system("cls");printf("文件打开错误\n");getch();exit(0);}fread(&class_num,sizeof(int),1,fp2);fread(records,sizeof(CLASS),class_num,fp1);fclose(fp1);fclose(fp2);}void quit(){char s[5];printf("确认退出\n");scanf("%s",s);if(s[0]=='y'||s[0]=='Y')exit(0);}void get(int i,int j){for(;;){printf("请输入发车时间(xx xx)");scanf("%s%s",records[i].hour,records[i].min);if((atoi(records[i].hour)<24&&atoi(records[i].hour)>=0)&&(atoi(records[i].min)<60& &atoi(records[i].min)>=0))break;else{printf("输入错误\n");getch();}}printf("请输入起点站:\n");scanf("%s",records[i].from);printf("请输入终点站:\n");scanf("%s",records[i].to);printf("请输入行车时间:\n");scanf("%f",&records[i].hours);printf("请输入额定载量:\n");scanf("%d",&records[i].max);for(;;){printf("请输入已售票数:\n");scanf("%d",&records[i].now);if(records[i].now<=records[i].max) break;else{printf("输入错误\n");getch();}}}int whether(int i){struct tm *local;time_t t;t=time(NULL); //NULL在stdio.h中定义为0local=localtime(&t); /////获取当前系统时间if(local->tm_hour<atoi(records[i].hour)||local->tm_hour==atoi(records[i].hour)&&local->tm_min<atoi(records[i].min))//atoi将字符串转换成一个整数值return 1;elsereturn 0;}。
火车票订票系统

include<stdio.h>//预处理函数include<stdlib.h>//标准库函数include<string.h>//字符串函数include<conio.h>//通过键盘来控制程序调试int o=0;typedef struct zuowei{int a;//车座int b;//车厢}seat;typedef struct Tmess{//定义一个结构体存储火车订票的信息char tnum8;//火车车次char time18;//发车时间char station18;//出发站char station28;//终点站char tujingstation8;//途经站char time28;//到站时间char money5;//票价}tmess;typedef struct in{//定义一个结构体存储火车座位信息tmess data;//调用火车的信息int reseat;//剩余票seat seatnum;struct in next;//定义next指针}in;typedef struct pmess{//定义一个结构体存储乘客信息char name10;//姓名char tel15;//电话char id20;//身份证char booknum3;//订票数目char checi8;//车次}pmess;typedef struct people{//乘客信息pmess m;//调用pmess结构体struct people next;//定义next指针}people;struct dingdan{int danhao;char tnum8;//火车车次char time18;//发车时间char station18;//出发站char station28;//终点站char tujingstation8;//途经站char time28;//到站时间char money5;char name10;//姓名char tel15;//电话char id20;//身份证char booknum3;//订票数目char seat10;char seatnum10;}dingdan100;void end;void admin;void bookin h;people k;void cancel;void chaxuntrainin h;in fangshiin h;char findmess;char numorcity; void print;void passenger;void putoutticketin p;void putticketin h;void widows;int main{forint i=0;i<100;i++{dingdani.danhao=i+1000;}in h;p;people k;v;int wp;h=inmalloc sizeof in;h->next=NULL;k=peoplemalloc sizeof people;k->next=NULL;p=h;v=k;while1{system"cls";widows;scanf"%d";℘fflushstdin;system"cls";switch wp{case 1:putticketh;break;case 2:chaxuntrainp;break;case 3:bookp;v;break;case 4:print;break;case 5:cancel;break;default:break;}printf"\n请按任何键结束\n";getch;}return 0;}void end{//结束页面函数puts"";printf" 谢谢使用\n";}void widows{//初始页面函数;printf"\n";printf" \n";printf" \n";printf" \n";printf" \n";printf" \n";printf" \n";printf" \n";printf" \n";printf" \n";printf"\n";printf" ☆1;输入车次信息\n";printf" ☆2;查询车次\n";printf" ☆3;订票\n";printf" ☆4;订单查询\n";printf" ☆5;退票 \n";printf" ☆6;退出系统 \n";printf" \n";printf"\n";printf" 请输入选择:";}void putticketin h{//输入车次信息in p;l;s;//定义了三个指针变量char num8;//定义了数组p=h;//p指向尾节点l=h->next;//l指针遍历火车信息while p->next{p=p->next;}while1{printf"请输入要添加的火车车次按0退出\n";scanf"%s";#fflushstdin;if strcmpnum;"0"==0break;while l{if strcmpl->data.tnum;num==0{//比较的输入车次与之前存在车次printf"该车次已经存在\n";return ;}l=l->next;//l++}s=in malloc sizeof in;strcpys->data.tnum;num;//复制函数;加入新的车次printf"请输入出发时间:\n";scanf"%s";&s->data.time1;fflushstdin;printf"请输入出发城市:\n";scanf"%s";&s->data.station1;fflushstdin;printf"请输入到达时间:\n";scanf"%s";&s->data.time2;fflushstdin;printf"请输入到达城市:\n";scanf"%s";&s->data.station2;fflushstdin;printf"请输入途径大站:\n";scanf"%s";&s->data.tujingstation;fflushstdin;printf"请输入票价:\n";scanf"%s";&s->data.money;fflushstdin;s->seatnum.a=1;s->seatnum.b=1;s->reseat=-1;s->next=NULL;p->next=s;p=s;}}void putoutticketin p{//打印火车信息printf"\n下面是火车信息\n";printf"车次:%s\n";p->data.tnum;printf"出发时间:%s\n";p->data.time1;printf"始发站:%s\n";p->data.station1;printf"到达时间:%s\n";p->data.time2;printf"终点站:%s\n";p->data.station2;printf"途经站:%s\n";p->data.tujingstation;printf"票价:%s\n";p->data.money;printf"剩余票数:%d";1000-p->reseat;}in fangshiin h;char findmess;char numorcity{//查询方式in p;if strcmpnumorcity;"num"==0{//按车次查询p=h->next;while p{if strcmpp->data.tnum;findmess==0{//查到与车次信息相符的return p;//返回所查到的信息}p=p->next;}}if strcmpnumorcity ;"city"==0{//按城市查询p=h->next;while p{if strcmpp->data.station2;findmess==0{//查到与城市信息相符的return p;//返回所查到的信息}p=p->next;}}return 0;}void chaxuntrainin h{//信息查询in p;char str110;int sel;if h->next==NULL{printf"没有任何火车信息\n";return ;}printf"\n请选择查询方式\n1.车次查询 2.城市查询\n";scanf"%d";&sel;fflushstdin;if sel==1{printf"请输入车次\n";scanf"%s";str1;fflushstdin;p=fangshih;str1;"num";if p{putoutticketp;}else {printf"\n没有找到\n";}}else if sel==2{printf"请输入到达城市\n";scanf"%s";str1;fflushstdin;p=fangshih;str1;"city";if p{putoutticketp;}else {printf"\n没有找到\n";}}}void bookin h;people k{//订票输入乘客信息;订票数in p;l;//定义两个in结构体下的指针变量people v;s;//定义两个people结构体下的指针变量int i=0;t=0;wp;i2=1;char str110;str210;//定义两个数组分别用来存储到达城市和车次信息l=h;v=k;extern int o;while v->nextv=v->next;//v指针遍历火车信息printf"请输入想要达到的城市\n";scanf"%s";&str1;fflushstdin;p=fangshil;str1;"city";//按城市搜索的查询方式printf"请输入想要的车次\n";scanf"%s";&str2;fflushstdin;p=fangshil;str2;"num";//按车次搜索的查询方式if p{printf"\n没有找到到达该城市的车次\n";return ;}else {putoutticketp;//调用outoutticket函数printf"是否要订这个车次<0/1>\n";scanf"%d";℘fflushstdin;if wp{s=peoplemalloc sizeof people;printf"请输入姓名:";scanf"%s";&s->;fflushstdin;printf"请输入电话:";scanf"%s";&s->m.tel;fflushstdin;printf"请输入身份证号:";scanf"%s";&s->m.id;fflushstdin;printf"请输入要订的票数:";scanf"%s";&s->m.booknum;fflushstdin;s->next=NULL;v->next=s;v=s;strcpys->m.checi;p->data.tnum;p->reseat=p->reseat+int atofs->m.booknum;if p->seatnum.a<8{sprintfdingdano.seatnum;"%d/%d";p->seatnum.a;p->seatnum.b;p->seatnum.a=p->seatnum.a+1;}elseif p->seatnum.b<8{sprintfdingdano.seatnum;"%d/%d";p->seatnum.a;p->seatnum.b;p->seatnum.b=p->seatnum.b+1;p->seatnum.a=1;}printf"\nOK订票成功\n";strcpydingdano.tnum;p->data.tnum;strcpydingdano.time1;p->data.time1;strcpydingdano.station1;p->data.station1;strcpydingdano.station2;p->data.station2;strcpydingdano.tujingstation;p->data.tujingstation;strcpydingdano.time2;p->data.time2;strcpydingdano.money;p->data.money;;s->;strcpydingdano.tel;s->m.tel;strcpydingdano.id;s->m.id;strcpydingdano.booknum;s->m.booknum;printf"订单号为:%d\n";dingdano.danhao;printf"座位号为:%s座位号/车厢号\n";dingdano.seatnum; o++;getch;}}}void cancel{int count=0;extern int o;char q5="失效";int p;int s=0;char passname20;printf"请输入乘客姓名:";scanf"%s/n";passname;forint i=0;i<o;i++{if strcmppassname;==0{printf"\n";printf" 这是订单号为%d的订单信息\n";dingdani.danhao;printf"\n";printf" 火车车次:%s\n";dingdani.tnum;printf" 发车时间:%s\n";dingdani.time1;printf" 出发站:%s\n";dingdani.station1;printf" 终点站:%s \n";dingdani.station2;printf" 途径站:%s \n";dingdani.tujingstation;printf" 到站时间:%s \n";dingdani.time2;printf" 票价:%s \n";dingdani.money;printf" 姓名:%s\n";;printf" 电话:%s\n";dingdani.tel;printf" 身份证:%s\n";dingdani.id;printf" 订票数目:%s\n";dingdani.booknum;printf" 座位号:%s<座位号/车厢号>\n";dingdani.seatnum;printf"\n";printf"----------------------------------------------------------------------------\n";count++;}}if count==0{printf"未找到该乘客的订票信息\n";goto low;}printf"请输入要删除的订单编号:";scanf"%d\n";&p;for s=0;s<o;s++{if p==dingdans.danhao{ strcpydingdans.tnum;q;strcpydingdans.time1;q;strcpydingdans.station1;q;strcpydingdans.station2;q;strcpydingdans.tujingstation;q;strcpydingdans.time2;q;strcpydingdans.money;q;;q;strcpydingdans.tel;q;strcpydingdans.id;q;strcpydingdans.booknum;q;printf"\n";printf" 这是订单号为%d的订单信息\n";dingdans.danhao;printf"\n";printf" 火车车次:%s\n";dingdans.tnum;printf" 发车时间:%s\n";dingdans.time1;printf" 出发站:%s\n";dingdans.station1;printf" 终点站:%s \n";dingdans.station2;printf" 途径站:%s \n";dingdans.tujingstation;printf" 到站时间:%s \n";dingdans.time2;printf" 票价:%s \n";dingdans.money;printf" 姓名:%s\n";;printf" 电话:%s\n";dingdans.tel;printf" 身份证:%s\n";dingdans.id;printf" 订票数目:%s\n";dingdans.booknum;printf" 座位号:%s<座位号/车厢号>\n";dingdani.seatnum;printf"\n";printf"----------------------------------------------------------------------------\n";}}low:;}void admin{int password=1;extern int o;int n;printf"请输入管理员密码:";scanf"%d\n";&n;fflushstdin;if password==n{forint i=0;i<o;i++{printf"\n";printf" 这是订单号为%d的订单信息\n";dingdani.danhao;printf"\n";printf" 火车车次:%s\n";dingdani.tnum;printf" 发车时间:%s\n";dingdani.time1;printf" 出发站:%s\n";dingdani.station1;printf" 终点站:%s \n";dingdani.station2;printf" 途径站:%s \n";dingdani.tujingstation;printf" 到站时间:%s \n";dingdani.time2;printf" 票价:%s \n";dingdani.money;printf" 姓名:%s\n";;printf" 电话:%s\n";dingdani.tel;printf" 身份证:%s\n";dingdani.id;printf" 订票数目:%s\n";dingdani.booknum;printf" 座位号:%s<座位号/车厢号>\n";dingdani.seatnum;printf"\n";printf"----------------------------------------------------------------------------\n";}}}void passenger{char passname20;printf"请输入乘客姓名:";scanf"%s/n";passname;fflushstdin;forint i=0;i<o;i++{if strcmppassname;==0{printf"\n";printf" 这是订单号为%d的订单信息\n";dingdani.danhao;printf"\n";printf" 火车车次:%s\n";dingdani.tnum;printf" 发车时间:%s\n";dingdani.time1;printf" 出发站:%s\n";dingdani.station1;printf" 终点站:%s \n";dingdani.station2;printf" 途径站:%s \n";dingdani.tujingstation;printf" 到站时间:%s \n";dingdani.time2;printf" 票价:%s \n";dingdani.money;printf" 姓名:%s\n";;printf" 电话:%s\n";dingdani.tel;printf" 身份证:%s\n";dingdani.id;printf" 订票数目:%s\n";dingdani.booknum;printf" 座位号:%s<座位号/车厢号>\n";dingdani.seatnum;printf"\n";printf"----------------------------------------------------------------------------\n";}}}void print{printf"\n";printf" 1:管理员登陆需管理员密码 \n";printf" 2:乘客登陆 \n";printf"\n";printf"请选择登录方式:";int m;scanf"%d\n";&m;fflushstdin;switch m{case 1:admin;break;case 2:passenger;break;default:break;}}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
C语言——订票系统代码部分:#include <conio.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <dos.h>#define HEADER1 " -------------------------------BOOK TICKET----------------------------------\n"#define HEADER2 " | number |start city|reach city|takeofftime|receivetime|price|ticketnumber|\n"#define HEADER3 " |----------|----------|----------|-----------|-----------|-----|------------|\n"#define FORMA T " |%-10s|%-10s|%-10s|%-10s |%-10s |%5d| %5d |\n"#define DA TA p->data.num,p->data.startcity,p->data.reachcity,p->data.takeofftime,p->data.receivetime,p->data.pr ice,p->data.ticketnumint saveflag=0 ;/*定义存储火车信息的结构体*/struct train{char num[10];/*列车号*/char startcity[10];/*出发城市*/char reachcity[10];/*目的城市*/char takeofftime[10];/*发车时间*/char receivetime[10];/*到达时间*/int price;/*票价*/int ticketnum ;/*票数*/};/*订票人的信息*/struct man{char num[10];/*ID*/char name[10];/*姓名*/int bookNum ;/*订的票数*/};– 1 –/*定义火车信息链表的结点结构*/typedef struct node{struct train data ;struct node * next ;}Node,*Link ;/*定义订票人链表的结点结构*/typedef struct Man{struct man data ;struct Man *next ;}book,*bookLink ;/* 初始界面*/void menu(){puts("\n\n");puts("\t\t|------------------------------------------------------|");puts("\t\t| Booking Tickets |");puts("\t\t|------------------------------------------------------|");puts("\t\t| 0:quit the system |");puts("\t\t| 1:Insert a train information |");puts("\t\t| 2:Search a train information |");puts("\t\t| 3:Book a train ticket |");puts("\t\t| 4:Modify the train information |");puts("\t\t| 5:Show the train information |");puts("\t\t| 6:save information to file |");puts("\t\t|------------------------------------------------------|");}/*添加一个火车信息*/void Traininfo(Link linkhead){struct node *p,*r,*s ;char num[10];r = linkhead ;s = linkhead->next ;while(r->next!=NULL)r=r->next ;while(1){printf("please input the number of the train(0-return)");– 2 –scanf("%s",num);if(strcmp(num,"0")==0)break ;/*判断是否已经存在*/while(s){if(strcmp(s->data.num,num)==0){printf("the train '%s'is existing!\n",num);return ;}s = s->next ;}p = (struct node*)malloc(sizeof(struct node));strcpy(p->data.num,num);/*输入车号*/printf("Input the city where the train will start:");scanf("%s",p->data.startcity);/*输入出发城市*/printf("Input the city where the train will reach:");scanf("%s",p->data.reachcity);/*输入到站城市*/printf("Input the time which the train take off:");scanf("%s",p->data.takeofftime);/*输入出发时间*/printf("Input the time which the train receive:");scanf("%s",&p->data.receivetime);/*输入到站时间*/printf("Input the price of ticket:");scanf("%d",&p->data.price);/*输入火车票价*/printf("Input the number of booked tickets:");scanf("%d",&p->data.ticketnum);/*输入预定票数*/p->next=NULL ;r->next=p ;/*插入到链表中*/r=p ;saveflag = 1 ;}}/*打印火车票信息*/void printheader() /*格式化输出表头*/{printf(HEADER1);printf(HEADER2);printf(HEADER3);}– 3 –void printdata(Node *q) /*格式化输出表中数据*/{Node* p;p=q;printf(FORMA T,DA TA);}/*查询火车信息*/void searchtrain(Link l){Node *s[10],*r;int sel,k,i=0 ;char str1[5],str2[10];if(!l->next){printf("There is not any record !");return ;}printf("Choose the way:\n1:according to the number of train;\n2:according to the city:\n");scanf("%d",&sel);/*输入选择的序号*/if(sel==1){printf("Input the the number of train:");scanf("%s",str1);r=l->next;while(r!=NULL)if(strcmp(r->data.num,str1)==0)/*检索是否有与输入的车号相匹配的*/{s[i]=r;i++;break;}elser=r->next;}else if(sel==2){printf("Input the city you want to go:");– 4 –scanf("%s",str2);r=l->next;while(r!=NULL)if(strcmp(r->data.reachcity,str2)==0)/*检索是否有与输入的城市相匹配的火车*/{s[i]=r;i++;r=r->next;}elser=r->next;}i f(i==0)printf("can not find!");else{printheader();for(k=0;k<i;k++)printdata(s[k]);}}/*订票子模块*/void Bookticket(Link l,bookLink k){Node *r[10],*p ;char ch[2],tnum[10],str[10],str1[10],str2[10];book *q,*h ;int i=0,t=0,flag=0,dnum;q=k ;while(q->next!=NULL)q=q->next ;printf("Input the city you want to go: ");scanf("%s",&str);/*输入要到达的城市*/p=l->next ;while(p!=NULL){if(strcmp(p->data.reachcity,str)==0){r[i]=p ;/*将满足条件的记录存到数组r中*/– 5 –i++;}p=p->next ;}printf("\n\nthe number of record have %d\n",i);printheader();for(t=0;t<i;t++)printdata(r[t]);if(i==0)printf("\nSorry!Can't find the train for you!\n");else{printf("\ndo you want to book it?<y/n>\n");scanf("%s",ch);if(strcmp(ch,"Y")==0||strcmp(ch,"y")==0)/*判断是否订票*/{h=(book*)malloc(sizeof(book));printf("Input your name: ");scanf("%s",&str1);strcpy(h->,str1);printf("Input your id: ");scanf("%s",&str2);strcpy(h->data.num,str2);printf("please input the number of the train:");scanf("%s",tnum);for(t=0;t<i;t++)if(strcmp(r[t]->data.num,tnum)==0){if(r[t]->data.ticketnum<1)/*判断剩余的供订票的票数是否为0*/{printf("sorry,no ticket!");sleep(2);return;}printf("remain %d tickets\n",r[t]->data.ticketnum);flag=1;break;}if(flag==0){– 6 –printf("input error");sleep(2);return;}printf("Input your bookNum: ");scanf("%d",&dnum);r[t]->data.ticketnum=r[t]->data.ticketnum-dnum;/*定票成功则可供订的票数相应减少*/h->data.bookNum=dnum ;h->next=NULL ;q->next=h ;q=h ;printf("\nLucky!you have booked a ticket!");getch();saveflag=1 ;}}}/*修改火车信息*/void Modify(Link l){Node *p ;char tnum[10],ch ;p=l->next;if(!p){printf("\nthere isn't record for you to modify!\n");return ;}else{printf("\nDo you want to modify it?(y/n)\n");getchar();scanf("%c",&ch);if(ch=='y'||ch=='Y'){printf("\nInput the number of the train:");scanf("%s",tnum);while(p!=NULL)if(strcmp(p->data.num,tnum)==0)/*查找与输入的车号相匹配的记录*/– 7 –break;elsep=p->next;if(p){printf("Input new number of train:");scanf("%s",&p->data.num);printf("Input new city the train will start:");scanf("%s",&p->data.startcity);printf("Input new city the train will reach:");scanf("%s",&p->data.reachcity);printf("Input new time the train take off");scanf("%s",&p->data.takeofftime);printf("Input new time the train reach:");scanf("%s",&p->data.receivetime);printf("Input new price of the ticket::");scanf("%d",&p->data.price);printf("Input new number of people who have booked ticket:");scanf("%d",&p->data.ticketnum);printf("\nmodifying record is sucessful!\n");saveflag=1 ;}elseprintf("\tcan't find the record!");}}}void showtrain(Link l)/*自定义函数显示列车信息*/{Node *p;p=l->next;printheader();if(l->next==NULL)printf("no records!");elsewhile(p!=NULL){printdata(p);p=p->next;}– 8 –}/*保存火车信息*/void SaveTrainInfo(Link l){FILE*fp ;Node*p ;int count=0,flag=1 ;fp=fopen("f:\\train.txt","wb");if(fp==NULL){printf("the file can't be opened!");return ;}p=l->next ;while(p){if(fwrite(p,sizeof(Node),1,fp)==1){p=p->next ;count++;}else{flag=0 ;break ;}}if(flag){printf(" saved %d train records\n",count);saveflag=0 ;}fclose(fp);}/*保存订票人的信息*/void SaveBookInfo(bookLink k){FILE*fp ;book *p ;int count=0,flag=1 ;– 9 –fp=fopen("f:\\man.txt","wb");if(fp==NULL){printf("the file can't be opened!");return ;}p=k->next ;while(p){if(fwrite(p,sizeof(book),1,fp)==1){p=p->next ;count++;}else{flag=0 ;break ;}}if(flag){printf(" saved %d booking records\n",count);saveflag=0 ;}fclose(fp);}main(){FILE*fp1,*fp2 ;Node *p,*r ;char ch1,ch2 ;Link l ;bookLink k ;book *t,*h ;int sel ;l=(Node*)malloc(sizeof(Node));l->next=NULL ;r=l ;– 10 –k=(book*)malloc(sizeof(book));k->next=NULL ;h=k ;fp1=fopen("f:\\train.txt","ab+");/*打开存储车票信息的文件*/if((fp1==NULL)){printf("can't open the file!");return 0 ;}while(!feof(fp1)){p=(Node*)malloc(sizeof(Node));if(fread(p,sizeof(Node),1,fp1)==1)/*从指定磁盘文件读取记录*/ {p->next=NULL ;r->next=p ;/*构造链表*/r=p ;}}fclose(fp1);fp2=fopen("f:\\man.txt","ab+");if((fp2==NULL)){printf("can't open the file!");return 0 ;}while(!feof(fp2)){t=(book*)malloc(sizeof(book));if(fread(t,sizeof(book),1,fp2)==1){t->next=NULL ;h->next=t ;h=t ;}}fclose(fp2);while(1){clrscr();menu();printf("\tplease choose (0~6): ");scanf("%d",&sel);clrscr();if(sel==0){if(saveflag==1)/*当退出时判断信息是否保存*/{getchar();printf("\nthe file have been changed!do you want to save it(y/n)?\n");scanf("%c",&ch1);if(ch1=='y'||ch1=='Y'){SaveBookInfo(k);SaveTrainInfo(l);}}printf("\nThank you!!Y ou are welcome too\n");break ;}switch(sel)/*根据输入的sel值不同选择相应操作*/{case 1 :Traininfo(l);break ;case 2 :searchtrain(l);break ;case 3 :Bookticket(l,k);break ;case 4 :Modify(l);break ;case 5:showtrain(l);break;case 6 :SaveTrainInfo(l);SaveBookInfo(k);break ;case 0:return 0;}printf("\nplease press any key to continue.......");getch();}}使用说明运行程序时,首先进入到菜单部分,菜单部分提供了菜单显示和输入功能部分。