C语言 车票管理系统源程序

合集下载

C语言程序--火车站售票系统程序

C语言程序--火车站售票系统程序

火车站售票查询系统:#include <conio.h>#include <stdio.h>#include <stdlib.h>#include <string.h>int shoudsave=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;/*票价*/int bookNum ;/*票数*/};/*订票人的信息*/struct man{char num[10];/*ID*/char name[10];/*某某*/int bookNum ;/*需求的票数*/};/*定义火车信息链表的结点结构*/typedef struct node{struct train data ;struct node * next ;}Node,*Link ;/*定义订票人链表的结点结构*/typedef struct people{struct man data ;struct people*next ;}bookMan,*bookManLink ;/* 初始界面*/void printInterface(){puts("********************************************************"); puts("* Wele 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("********************************************************"); }/*添加一个火车信息*/void InsertTraininfo(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)");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 ;}}/*打印火车票信息*/void printTrainInfo(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,char findmess[],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 ;}/*查询火车信息*/void QueryTrain(Link l){Node *p ;int sel ;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!");}}}/*订票子模块*/void BookTicket(Link l,bookManLink k){Node*r[10],*p ;char ch,dem ;bookMan*v,*h ;int i=0,t=0 ;char str[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(bookManLink k,char findmess[]){bookMan*r ;r=k->next ;while(r){if(strcmp(r->data.num,findmess)==0){mark=1 ;return r ;}r=r->next ;}return 0 ;}/*修改火车信息*/void UpdateInfo(Link l){Node*p ;char findmess[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 ;}}/*系统给用户的提示信息*/void AdvicedTrains(Link l){Node*r ;char str[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");}/*保存火车信息*/void SaveTrainInfo(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 ;}}/*保存订票人的信息*/void SaveBookmanInfo(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 ;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);{clrscr();printInterface();printf("please choose the operation: ");scanf("%d",&sel);clrscr();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 wele 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();}}。

C语言程序设计_火车订票系统程序设计报告

C语言程序设计_火车订票系统程序设计报告

设计题目:火车订票系统设计专业:电子信息工程班级: 09级3班姓名:学号:目录一总体设计(包含几大功能模块) (1)二详细设计(各功能模块的具体实现算法——流程图) (2)三调试分析(包含各模块的测试用例,及测试结果) (3)3.1源程序 (6)3.2调试与测试 (31)四总结 (33)一总体设计(包含几大功能模块)1.Insert a train information(插入火车信息)2.inquire a train jinformation(查询火车信息)3.Book a train ticket(订票)4.Update the train information(更新火车信息)5.Advice to you about the train (建议)6.Save information to file(储存信息归档)7.Quit the system(退出系统)二、详细设计(各功能模块的具体实现算法——流程图)2.1各函数的功能和实现1.Insert a train information(插入火车信息):输入包括火车班次,最终目地,始发站,火车到站时间,车票价格,所定票号。

可用函数void input来实现此操作2.inquire a train jinformation(查询火车信息):没有任何记录3.Book a train ticket(订票):输入你想要去的城市4.Update the train information(更新火车信息):可用void find()来实现5.Advice to you about the train (关于火车对你的建议)6.Save information to file(储存信息归档)7.Quit the system(退出系统):可用一个函数exit()来实现,首先将信息保存到文件中,释放动态创建的内存空间,再退出此程序。

流程图详见A4纸上手绘三调试分析(包含各模块的测试用例,及测试结果)3.1源程序#include <conio.h>#include <stdio.h>#include <stdlib.h>#include <string.h>int shoudsave=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;/*票价*/int bookNum ;/*票数*/};/*订票人的信息*/struct man{char num[10];/*ID*/char name[10];/*姓名*/int bookNum ;/*需求的票数*/ };/*定义火车信息链表的结点结构*/ typedef struct node{struct train data ;struct node * next ;}Node,*Link ;/*定义订票人链表的结点结构*/ typedef struct people{struct man data ;struct people*next ;}bookMan,*bookManLink ;/* 初始界面*/void printInterface(){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("********************************************************"); }/*添加一个火车信息*/void InsertTraininfo(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)"); 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 ;}}/*打印火车票信息*/void printTrainInfo(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,char findmess[],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 ;}/*查询火车信息*/void QueryTrain(Link l){Node *p ;int sel ;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!"); }}}/*订票子模块*/void BookTicket(Link l,bookManLink k){Node*r[10],*p ;char ch,dem ;bookMan*v,*h ;int i=0,t=0 ;char str[10],str1[10],str2[10];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(bookManLink k,char findmess[]){bookMan*r ;r=k->next ;while(r){if(strcmp(r->data.num,findmess)==0){mark=1 ;return r ;}r=r->next ;}return 0 ;}/*修改火车信息*/void UpdateInfo(Link l){Node*p ;char findmess[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 ;}}/*系统给用户的提示信息*/void AdvicedTrains(Link l){Node*r ;char str[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");}/*保存火车信息*/void SaveTrainInfo(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);}/*保存订票人的信息*/void SaveBookmanInfo(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 ;int sel ;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 ;}}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 ;}}fclose(fp2);while(1){clrscr();printInterface();printf("please choose the operation: ");scanf("%d",&sel);clrscr();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;}3.2调试与测试主要程序运行结果:运行开始选择1输入信息:选择2查询信息选择3订票选择4没用选择5对你的建议选择7退出系统3. 心得体会通过这次课程设计,增加了我对软件技术的了解,虽然还不明确软件技术包含的具体内容,但从学习C语言这门课程开始,已发现程序设计的好处,他对我们数学的学习也有很大的帮助。

课程设计报告_车票管理系统

课程设计报告_车票管理系统

湖南工业大学课程设计(实训)资料学院计算机学院2018-2019 学年第 1 学期课程名称面向过程程序设计(C语言)课程设计指导教师xxx 学生姓名xxx 专业班级计算机类xxx 学号xxx题目车票管理系统起止日期2019 年12 月23 日~2019 年 1 月 2 日目录清单课程设计(实训)任务书学院:计算机学院学生姓名:xxx 专业班级:xxx课程名称:面向过程程序设计(C语言)课程设计设计题目:车票管理系统完成期限:自2018 年12 月23 日至2019 年 1 月 2 日共1周指导教师(签字):年月日系(教研室)主任(签字):年月日课程设计(实训)报告课程名称:面向过程程序设计(C语言)课程设计题目:车票管理系统起止日期:2018 年12 月23 日至2019 年1 月2 日学院计算机学院学生姓名xxx班级计算机类xxx学号xxx成绩指导教师(签字)2019 年1 月目录1 课题简介 (5)1.1系统简介 (5)1.2开发环境及开发工具 (5)2 问题分析 (6)2.1需求分析 (6)2.2问题分析 (7)2.3系统中涉及到的相关算法 (8)3 系统设计 (10)3.1系统功能设计 (10)3.2系统的功能分析 (12)4 系统的实现 (13)4.1系统主函数设计 (13)4.2录入和增加班次模块 (14)4.3查询和浏览模块 (18)4.4售退票模块 (23)5 系统测试 (27)5.1软件测试 (27)5.2系统有效性 (27)6 设计总结 (27)参考文献 (28)1 课题简介1.1系统简介通过这次系统开发的经历,通过查询各种书籍以及网上视频去学会怎样灵活地去运用C语言设计编写一些小功能函数,并且结合课上所学的的知识,将呆板的文字知识变成实际的动手能力,通过编写课程设计,去体会逻辑思维和设计算法能力的重要性,并且要知道编写代码应该思路清晰,格式整齐,简单易懂为主。

我也需要去发现所学知识中的漏洞,并且及时翻找资料完善不足以提高自身水平、完善自身。

c语言课程设计车票管理系统

c语言课程设计车票管理系统

c语言课程设计车票管理系统车票管理系统是一种用于管理车票信息的软件系统,它可以方便地记录和查询车票的相关信息,包括车票的购买、使用和退款等操作。

本文将详细介绍车票管理系统的设计与实现。

一、系统需求分析车票管理系统的主要功能包括:车票信息的录入与管理、车票的购买与退款、车票的查询与打印等。

具体需求如下:1. 车票信息的录入与管理:系统管理员可以录入车票的基本信息,包括车次、出发地、目的地、出发时间、到达时间、票价等。

2. 车票的购买与退款:乘客可以通过系统购买车票,并可以根据需要进行退款操作。

购买车票时需要提供乘客的相关信息,包括姓名、身份证号、联系电话等。

3. 车票的查询与打印:乘客可以通过系统查询车票的相关信息,并可以选择打印车票。

二、系统设计与实现1. 数据库设计:为了存储车票的相关信息,需要设计一个车票信息表,包括车次、出发地、目的地、出发时间、到达时间、票价等字段。

同时,还需要设计一个乘客信息表,包括姓名、身份证号、联系电话等字段。

2. 界面设计:车票管理系统的界面应该简洁明了,方便用户操作。

可以采用图形界面的形式,通过按钮、输入框等控件与用户进行交互。

3. 功能实现:a. 车票信息的录入与管理:系统管理员可以通过系统界面进行车票信息的录入与管理,包括新增车票、修改车票、删除车票等操作。

b. 车票的购买与退款:乘客可以通过系统界面选择购买车票或退款,购买车票时需要填写相关信息,并将购买信息保存到数据库中,退款时需要输入订单号进行操作。

c. 车票的查询与打印:乘客可以通过系统界面进行车票的查询,可以根据车次、出发地、目的地、出发时间等条件进行筛选,并可以选择打印车票。

三、系统运行流程1. 系统管理员登录系统,进入车票管理界面。

2. 管理员可以进行车票信息的录入与管理,包括新增、修改和删除车票。

3. 乘客通过系统界面选择购买车票,填写相关信息,系统将购买信息保存到数据库中,并生成订单号。

4. 乘客可以通过系统界面进行车票的查询,可以根据条件筛选需要的车票。

c语言课程设计车票管理系统

c语言课程设计车票管理系统

c语言课程设计车票管理系统一、教学目标本节课的教学目标是使学生掌握C语言编程的基本方法,通过编写“车票管理系统”程序,让学生了解和掌握结构体、文件操作等高级知识,培养学生的实际编程能力和问题解决能力。

具体分为以下三个部分:1.知识目标:使学生掌握结构体的定义和使用,理解文件操作的基本方法,了解C语言编程中的一些常见问题和解决方法。

2.技能目标:培养学生能够运用C语言进行程序设计,能够独立完成一个小型管理系统的设计与实现。

3.情感态度价值观目标:培养学生对计算机科学的兴趣,提高学生解决实际问题的能力,培养学生的团队协作精神。

二、教学内容本节课的教学内容主要包括以下几个部分:1.结构体的定义和使用:通过讲解和示例,让学生了解结构体的概念和如何使用结构体来表示车票信息。

2.文件操作:讲解如何使用C语言进行文件的读写操作,让学生掌握文件操作的基本方法。

3.车票管理系统的设计与实现:通过分组讨论和实验,让学生设计和实现一个简单车票管理系统,培养学生的实际编程能力和问题解决能力。

三、教学方法本节课的教学方法主要包括讲授法、讨论法和实验法:1.讲授法:用于讲解结构体和文件操作的基本概念和方法。

2.讨论法:通过分组讨论,让学生共同探讨如何设计和实现车票管理系统。

3.实验法:让学生动手编写程序,实现车票管理系统的功能。

四、教学资源本节课的教学资源主要包括教材、参考书、多媒体资料和实验设备:1.教材:主要包括C语言编程教材和《C程序设计》等。

2.参考书:主要包括《C语言 Primer》等。

3.多媒体资料:包括结构体和文件操作的PPT讲解,以及相关的视频教程。

4.实验设备:包括计算机和网络设备,让学生能够进行实际的编程和实验操作。

五、教学评估本节课的教学评估主要包括以下几个部分:1.平时表现:通过观察学生在课堂上的参与程度、提问回答等情况,评估学生的学习态度和理解程度。

2.作业:通过检查学生提交的作业,评估学生对结构体和文件操作知识的掌握情况。

C语言编程---火车订票系统源代码之欧阳学创编

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;}。

车票管理系统C 课程设计

-6-
石河子大学信息科学与技术学院电子信息工程专业课程设计报告
} void Bus_infor::ShowTime(){
cout<<Hour_start<<":"<<Minute_start<<" "; cout<<Hour_end<<":"<<Minute_end<<" "; cout<<Hour<<":"<<Minute<<endl; } Bus_infor::Bus_infor(){ No=Bus_No++; tickted=0; } Bus_infor::~Bus_infor(){ Bus_No--; } //set the addr void Bus_infor::addr(){ cout<<"请输入起始站与终点站:"<<endl; char a[20];char b[20]; cin>>a;cin>>b; strcpy(start,a);strcpy(end,b); } //Get the start addr char *Bus_infor::Get_start(){ return start; } //Get the end addr char *Bus_infor::Get_end(){ return end; } //Get the no int Bus_infor::Get_no(){ return No; } int Bus_infor::Get_all_tickted(){ return all_tickted; } int Bus_infor::Get_tickted(){ return tickted; } int Bus_infor::Get_bus_order(){ return Bus_order; } //order the tickt void Bus_infor::Order_tickt(int n){ tickted=tickted+n; } void Bus_infor::Unorder_tickt(int n){ tickted=tickted-n; }; class Bus_link{ public: Bus_link(){head=new Bus_infor;head->next=NULL;key=0;} //~Bus_link(){delete head;} void input();

c++ 车票管理系统+工资管理系统

车票管理系统(C语言实现)/******************************************************************************* ************************************车票管理系统一车站每天有n个发车班次,每个班次都有一班次号(1、2、3…n),固定的发车时间,固定的路线(起始站、终点站),大致的行车时间,固定的额定载客量。

如班次发车时间起点站终点站行车时间额定载量已定票人数1 8:00 郫县广汉2 45 302 6:30 郫县成都 0.5 40 403 7:00 郫县成都 0.5 40 204 10:00 郫县成都 0.5 40 2…(一)功能要求:用c/c++设计一系统,能提供下列服务:(1)录入班次信息(信息用文件保存),可不定时地增加班次数据(2)浏览班次信息,可显示出所有班次当前状态(如果当前系统时间超过了某班次的发车时间,则显示“此班已发出”的提示信息)。

(3)查询路线:可按班次号查询 ,可按终点站查询(4)售票和退票功能A:当查询出已定票人数小于额定载量且当前系统时间小于发车时间时才能售票,自动更新已售票人数B:退票时,输入退票的班次,当本班车未发出时才能退票,自动更新已售票人数(二)其它要求:(1) 只能使用C/C++语言,源程序要有适当的注释,使程序容易阅读(2) 至少采用文本菜单界面(如果能采用图形菜单界面更好)(3) 学生可自动增加新功能模块******************************************************************************** ***********************************/#include<stdio.h>#include<stdlib.h>#include<dos.h>#include<time.h>#include<conio.h>#include<string.h>const int MAX=20;const int N=50;const int MAXFILENAME=100;enum {FALSE,TRUE};struct time{int hour;int minutes;};struct ticket{int SerialNumber;struct time SetOut;char DeparturePoint[MAX];char TerminalPoint[MAX];float LastTime;int FixNumber;int FixedNumber;}car[N];int RecordNumber;int FLAG=FALSE;/**********************************************/int ShowMessage(void); //载入原始数据void mainmenu(void); //主菜单void InsertMessage(void); //录入班次信息void SearchMenu(void); //查询路线子菜单void SearchByNumber(void); //按班次号查询void SearchByAddress(void); //按终点站查询void TicketManagement(void); //车票售出与退回void TicketOrder(void); //售票void TicketDelete(void); //退票void exit(void); //退出该系统/********************************************/int main(void){RecordNumber=ShowMessage();if(1)do{mainmenu();}while(FLAG==FALSE);return 0;}void mainmenu(void){system("color 1f");system("mode con: cols=140 lines=130");char functionNumber;printf(" 车票管理系统\n\n");printf(" 制作:hmm182007\n");printf(" 日期:2007/11/25/19:57\n");printf("======================================================================== ====\n");printf(" 1.录入班次信息\t\n");printf(" 2.浏览班次信息\t\n");printf(" 3.查询行车路线\t\n");printf(" 4.售票与退票系统\t\n");printf(" 5.退出该系统\t\n");printf("======================================================================== ====\n");printf("请选择你所需要的功能:");scanf("%c",&functionNumber);switch(functionNumber){case '1':{InsertMessage();printf("\n按任意键回主菜单......\n");getchar();getchar();}break;case '2':{ShowMessage();printf("\n按任意键回主菜单......\n");getchar();getchar();}break;case '3':{SearchMenu();printf("\n按任意键回主菜单......\n");getchar();getchar();}break;case '4':{TicketManagement();getchar();getchar();}break;case '5':FLAG=TRUE;exit();break;default:{printf("输入错误,请确保你的输入为1--5.\n");printf("按任意键回主菜单......\n");getchar();getchar();}}//switch endsFLAG=FALSE;}void InsertMessage(void){FILE *fp;char filename[MAXFILENAME];int i;printf("请输入文件名或者文件路径名:");scanf("%s",filename);if((fp=fopen(filename,"r"))==NULL){printf("文件%s不可读,请确认文件%s存在或者文件路径正确.\n\n",filename,filename);mainmenu();}for(i=RecordNumber;!feof(fp)&&!ferror(fp);i++){fscanf(fp,"%d%d%d",&car[i].SerialNumber,&car[i].SetOut.hour,&car[i].SetOut.minut es);fscanf(fp,"%s%s%f%d%d",&car[i].DeparturePoint,&car[i].TerminalPoint,&car[i].Last Time,&car[i].FixNumber,&car[i].FixedNumber);}int count=i;printf("班次\t发车时间\t起点\t终点\t行车时间(小时)\t额定载量\t已定票人数\n"); for(i=0;i<count;i++){printf("%d\t%d:%d\t\t",car[i].SerialNumber,car[i].SetOut.hour,car[i].SetOut.minu tes);printf("%s\t%s\t\t%.1f\t %d\t\t%d\n",car[i].DeparturePoint,car[i].TerminalPoint, car[i].LastTime,car[i].FixNumber,car[i].FixedNumber);}fclose(fp);}int ShowMessage(void){int i;FILE *fp;if((fp=fopen("add.txt","r"))==NULL){printf("读取数据失败,请检查文件add.txt是否存在.\n");exit(-1);}for(i=0;!feof(fp)&&!ferror(fp);i++){fscanf(fp,"%d%d%d",&car[i].SerialNumber,&car[i].SetOut.hour,&car[i].SetOut.minut es);fscanf(fp,"%s%s%f%d%d",&car[i].DeparturePoint,&car[i].TerminalPoint,&car[i].Last Time,&car[i].FixNumber,&car[i].FixedNumber);}int count=i;printf("班次\t发车时间\t起点\t终点\t行车时间(小时)\t额定载量\t已定票人数\n"); for(i=0;i<count;i++){printf("%d\t%d:%d\t\t",car[i].SerialNumber,car[i].SetOut.hour,car[i].SetOut.minu tes);printf("%s\t%s\t\t%.1f\t %d\t\t%d\n",car[i].DeparturePoint,car[i].TerminalPoint, car[i].LastTime,car[i].FixNumber,car[i].FixedNumber);}return count;}void SearchMenu(void){system("color 1f");system("mode con: cols=140 lines=130");char functionNumber;printf(" 查询子菜单\n");printf("======================================================================== ====\n");printf(" 1.按班次号查询\t\n");printf(" 2.按终点站查询\t\n");printf(" 3.返回主菜单\t\n");printf("======================================================================== ====\n");printf("请选择你所需要的功能:");scanf("%*c%c",&functionNumber);switch(functionNumber){case '1':SearchByNumber();break;case '2':SearchByAddress();break;case '3':getchar();mainmenu();break;default:printf("输入错误,请确保你的输入为1--3.\n");printf("按任意键回查询子菜单......\n");getchar();getchar();SearchMenu();}}void SearchByNumber(void){int SearchNumber;printf("请输入要查询的班次号:");scanf("%d",&SearchNumber);printf("班次\t发车时间\t起点\t终点\t行车时间(小时)\t额定载量\t已定票人数\n"); printf("%d\t%d:%d\t\t",car[SearchNumber-1].SerialNumber,car[SearchNumber-1].SetO ut.hour,car[SearchNumber-1].SetOut.minutes);printf("%s\t%s\t\t%.1f\t %d\t\t%d\n",car[SearchNumber-1].DeparturePoint,car[Sear chNumber-1].TerminalPoint,car[SearchNumber-1].LastTime,car[SearchNumber-1].FixNu mber,car[SearchNumber-1].FixedNumber);}void SearchByAddress(void){int i;char Address[MAX];printf("请输入终点站的名称:");scanf("%s",&Address);printf("班次\t发车时间\t起点\t终点\t行车时间(小时)\t额定载量\t已定票人数\n"); for(i=0;i<RecordNumber;i++){//对比终点站记录,找到并输出if((strcmp(Address,car[i].TerminalPoint))==0){printf("%d\t%d:%d\t\t",car[i].SerialNumber,car[i].SetOut.hour,car[i].SetOut.minu tes);printf("%s\t%s\t\t%.1f\t %d\t\t%d\n",car[i].DeparturePoint,car[i].TerminalPoint,car[i].LastTime,car[i].FixNumber,car[i].FixedNumber);}}}void TicketManagement(void){char functionNumber;system("color 1f");system("mode con: cols=140 lines=130");printf(" 订票与退票菜单\n");printf("======================================================================== ====\n");printf(" 1.订票\t\n");printf(" 2.退票\t\n");printf(" 3.返回主菜单.\n");printf("======================================================================== ====\n");printf("选择你需要的功能:");scanf("%*c%c",&functionNumber);switch(functionNumber){case '1':{TicketOrder();//getchar();//getchar();}break;case '2':TicketDelete();break;case '3':{getchar();mainmenu();}break;default:{printf("输入错误,请确保你的输入为1--3.\n");printf("按任意键回主菜单......\n");getchar();getchar();mainmenu();}}}void TicketOrder(void){int i;printf("请输入要订购的车票的班次:");scanf("%d",&i);if(i<0||i>RecordNumber){printf("对不起,今天没有这趟车,请明天再来,谢谢使用!\n");printf("按任意键回主菜单......\n");getchar();//getchar();TicketManagement();}time_t tval;struct tm *now;tval = time(NULL);now = localtime(&tval);if((now->tm_hour==car[i].SetOut.hour&&now->tm_min<car[i].SetOut.minutes)||(now-> tm_hour<car[i].SetOut.hour)){if(car[i].FixedNumber<car[i].FixNumber){car[i].FixedNumber++;printf("你的订票成功,请按时上车,谢谢使用!\n");}else printf("对不起,今天的这趟车的票已卖完,请明天再来,谢谢合作!\n");}else printf("对不起,今天的这趟车已发出,请明天再来,谢谢合作!\n");printf("班次\t发车时间\t起点\t终点\t行车时间(小时)\t额定载量\t已定票人数\n"); printf("%d\t%d:%d\t\t",car[i-1].SerialNumber,car[i-1].SetOut.hour,car[i-1].SetOu t.minutes);printf("%s\t%s\t\t%.1f\t %d\t\t%d\n",car[i-1].DeparturePoint,car[i-1].TerminalPo int,car[i-1].LastTime,car[i-1].FixNumber,car[i-1].FixedNumber);//printf("按任意键回主菜单......\n");//getchar();getchar();}void TicketDelete(void){int i;printf("请输入要退购的车票的班次:");scanf("%d",&i);if(i<0||i>RecordNumber){printf("对不起,今天没有这趟车,无法完成退票.谢谢使用!\n");getchar();//getchar();TicketManagement();getchar();}time_t tval;struct tm *now;tval = time(NULL);now = localtime(&tval);if((now->tm_hour==car[i].SetOut.hour&&now->tm_min<car[i].SetOut.minutes)||(now-> tm_hour<car[i].SetOut.hour)){if(car[i].FixedNumber>=1){car[i].FixedNumber--;printf("退订车票成功,谢谢使用!\n");}else printf("对不起,今天的这趟车的票尚未卖出,无法完成退票!\n");}else printf("对不起,今天的这趟车已发出,无法完成退票!\n");printf("班次\t发车时间\t起点\t终点\t行车时间(小时)\t额定载量\t已定票人数\n");printf("%d\t%d:%d\t\t",car[i-1].SerialNumber,car[i-1].SetOut.hour,car[i-1].SetOu t.minutes);printf("%s\t%s\t\t%.1f\t %d\t\t%d\n",car[i-1].DeparturePoint,car[i-1].TerminalPo int,car[i-1].LastTime,car[i-1].FixNumber,car[i-1].FixedNumber);getchar();//getchar();}void exit(void){printf("\n\n*********************谢谢使用本系统,欢迎下次继续使用***********************\n");exit(0);}#include<stdio.h>#include<time.h>#include<string.h>typedef struct information{int numb;char starttime[10];char begin[21];char end[21];float lasttime;int canload;int alreadyload;}INFORMATION;void AddInformation(void){FILE *fp;INFORMATION info;printf("please input the information you want to insert,input 0 to return back:\n");scanf("%d", &info.numb);if(info.numb == 0) return;scanf("%s%s%s%f%d%d", info.starttime, info.begin, info.end, &sttime, &info.canload, &info.alreadyload);if((fp = fopen("c:\\information.txt", "a+")) == 0){printf("open file error!");exit(0);}fprintf(fp, "%d %s %s %s %f %d %d\n", info.numb, info.starttime, info.begin, info.end, sttime, info.canload, info.alreadyload);fclose(fp);}int GetHour(char *s){char *p, *q;p = (char *)malloc(10);strcpy(p, s);q = p;while(*q != ':'){q++;}*q = '\0';return atoi(p);}int GetMinute(char *s){char *p;p = (char *)malloc(10);strcpy(p, s);while(*p != ':'){p++;}p++;return atoi(p);}void ShowInformation(void){FILE *fp;INFORMATION info;time_t t;struct tm *timeinfo;if((fp = fopen("c:\\information.txt", "r+")) == 0){printf("open file error!");exit(0);}time(&t);timeinfo = localtime(&t);while(!feof(fp)){fscanf(fp, "%d%s%s%s%f%d%d\n", &info.numb, info.starttime, info.begin, info.end, &sttime, &info.canload, &info.alreadyload);printf("%d %s %s %s %f %d %d ", info.numb, info.starttime, info.begin, info.end, sttime, info.canload, info.alreadyload);if(GetHour(info.starttime) < timeinfo->tm_hour) printf("此班已发出!\n");else if(GetHour(info.starttime) == timeinfo->tm_hour){if(GetMinute(info.starttime)<=timeinfo->tm_min) printf("此班已发出!\n");else printf("\n");}else printf("\n");}fclose(fp);}void SearchbyNum(void){FILE *fp;INFORMATION info;int bc;printf("please input the number,input 0 to return back:\n");scanf("%d", &bc);if(0 == bc) return;if((fp = fopen("c:\\information.txt", "r+")) == 0){printf("open file error!");exit(0);}while(!feof(fp)){fscanf(fp, "%d%s%s%s%f%d%d\n", &info.numb, info.starttime, info.begin, info.end, &sttime, &info.canload, &info.alreadyload);if(info.numb == bc){printf("%d %s %s %s %f %d %d\n", info.numb, info.starttime, info.begin, info.end, sttime, info.canload, info.alreadyload);}}fclose(fp);}void SearchbyEnd(void){FILE *fp;INFORMATION info;char zhongdian[100];printf("please input the place,input 0 to return back:\n");scanf("%s", zhongdian);if(strcmp(zhongdian, "0") == 0) return;if((fp = fopen("c:\\information.txt", "r+")) == 0){printf("open file error!");exit(0);while(!feof(fp)){fscanf(fp, "%d%s%s%s%f%d%d\n", &info.numb, info.starttime, info.begin, info.end, &sttime, &info.canload, &info.alreadyload);if(strcmp(zhongdian, info.end) == 0){printf("%d %s %s %s %f %d %d\n", info.numb, info.starttime, info.begin, info.end, sttime, info.canload, info.alreadyload);}}fclose(fp);}void SearchWay(void){int i;printf("1. search by number\n");printf("2. search by end\n");printf("0. return back\n");printf("which way do you want?\n");scanf("%d", &i);switch(i){case 1: SearchbyNum(); break;case 2: SearchbyEnd(); break;case 0: return;default : break;}}void Buy(void){FILE *fp;INFORMATION info;time_t t;struct tm *timeinfo;int bc;long pos, pos1;printf("please input the banci you want to buy,input 0 to return back:\n"); scanf("%d", &bc);if(0 == bc) return;if((fp = fopen("c:\\information.txt", "r+")) == 0)printf("open file error!");exit(0);}time(&t);timeinfo = localtime(&t);while(1){pos1 = ftell(fp);fscanf(fp, "%d%s%s%s%f%d%d\n", &info.numb, info.starttime, info.begin, info.end, &sttime, &info.canload, &info.alreadyload);pos = ftell(fp) - pos1;if(info.numb == bc){if(info.alreadyload < info.canload){if(GetHour(info.starttime) < timeinfo->tm_hour){printf("sorry, the plane has taken off!");}else if(GetHour(info.starttime) == timeinfo->tm_hour){if(GetMinute(info.starttime) <= timeinfo->tm_min) printf("sorry, the plane has taken off!");else{printf("take your ticket, bye!");info.alreadyload ++;fseek(fp, -pos, SEEK_CUR);fprintf(fp, "%d %s %s %s %f %d %d\n", info.numb, info.starttime, info.begin, info.end, sttime, info.canload, info.alreadyload);}}else{printf("take your ticket, bye!");info.alreadyload ++;fseek(fp, -pos, SEEK_CUR);fprintf(fp, "%d %s %s %s %f %d %d\n", info.numb, info.starttime, info.begin, info.end, sttime, info.canload, info.alreadyload);}}else printf("sorry, the tickets are all sold out!");break;}}fclose(fp);}void Cancel(void){FILE *fp;INFORMATION info;time_t t;struct tm *timeinfo;int bc;long pos, pos1;printf("please input the banci you want to cancel,input 0 to return back:\n"); scanf("%d", &bc);if(0 == bc) return;if((fp = fopen("c:\\information.txt", "r+")) == 0){printf("open file error!");exit(0);}time(&t);timeinfo = localtime(&t);while(1){pos1 = ftell(fp);fscanf(fp, "%d%s%s%s%f%d%d\n", &info.numb, info.starttime, info.begin, info.end, &sttime, &info.canload, &info.alreadyload);pos = ftell(fp) - pos1;if(info.numb == bc){if(GetHour(info.starttime) < timeinfo->tm_hour){printf("sorry, the plane has taken off!");}else if(GetHour(info.starttime) == timeinfo->tm_hour){if(GetMinute(info.starttime) <= timeinfo->tm_min) printf("sorry, the plane has taken off!");else{printf("your ticket is canceled, bye!");info.alreadyload --;fseek(fp, -pos, SEEK_CUR);fprintf(fp, "%d %s %s %s %f %d %d\n", info.numb, info.starttime, info.begin, info.end, sttime, info.canload, info.alreadyload);}}else{printf("your ticket is canceled, bye!");info.alreadyload --;fseek(fp, -pos, SEEK_CUR);fprintf(fp, "%d %s %s %s %f %d %d\n", info.numb, info.starttime, info.begin, info.end, sttime, info.canload, info.alreadyload);}break;}}fclose(fp);}void ForTicket(void){int i;printf("1. I want to buy a ticket\n");printf("2. I want to return a ticket\n");printf("0. return back\n");printf("which do you want?");scanf("%d", &i);switch(i){case 1: Buy(); break;case 2: Cancel(); break;case 0: return;default : break;}}int main(){int i;while(1){printf("\n1. 录入班次信息\n");printf("2. 浏览班次信息\n");printf("3. 查询路线\n");printf("4. 售票退票\n");printf("\nPlease input a number from 1 to 4 like above ,use 0 to exit!\n"); scanf("%d",&i);switch(i){case 0: return 0;case 1: AddInformation(); break;case 2: ShowInformation(); break;case 3: SearchWay(); break;case 4: ForTicket(); break;default :printf("Wrong number!\n"); break;}}}工资管理系统#include<iostream.h>#include<stdio.h>#include<stdlib.h>#include<string.h>#define FILENAME "staff.txt" //数据文件/////////////////////////////////////////////struct Staff //职工机构体{char CarNumber[10]; //卡号char Name[10]; //姓名int Month; //月份float SPWages; //应发工资float APWages; //实发工资float Water; //水费float Electrical; //电费float Tax; //税金};////////////////////////////////////////////// 文件操作模块FILE *FP; //全局文件指针FILE * FileOpen(char FileName[]) //文件打开函数{FILE *fp;if((fp=fopen(FileName,"r"))==NULL){fp=fopen(FileName,"w");cout<<"文件打开失败重新创建记录文件";return fp;}fp=fopen(FileName,"r+");return fp;}void FileClose(FILE *fp){if(fclose(fp)==0)cout<<"安全关闭"<<endl;elsecout<<"文件关闭失败"<<endl;}////////////////////////////////////////////////void Increase() //添加职工信息{FP=FileOpen(FILENAME);Staff temp;cout<<endl;cout<<"请输入姓名:";cin>>;cout<<"请输入卡号:";cin>>temp.CarNumber;cout<<"请输入月份:";cin>>temp.Month;cout<<"请输入应发工资:";cin>>temp.SPWages;cout<<"请输入水费:";cin>>temp.Water;cout<<"请输入电费:";cin>>temp.Electrical;if(temp.SPWages<=800) temp.Tax=0;if((temp.SPWages>800.0)&&(temp.SPWages<1400.0))temp.Tax=(temp.SPWages-800)*0.05;if(temp.SPWages>1400){temp.Tax=(temp.SPWages-1400)*0.1;} temp.APWages=temp.SPWages-temp.Water-temp.Electrical-temp.Tax; fwrite(&temp,sizeof(temp),1,FP);cout<<"信息添加成功,请选择浏览工资信息选项进行查看"<<endl; FileClose(FP);}//////////////////////////////////////////////void PrintInformation() //浏览工资信息FP=FileOpen(FILENAME);rewind(FP);Staff temp;while(fread(&temp,sizeof(Staff),1,FP)==1){cout<<"姓名:"<<<<endl;cout<<"卡号:"<<temp.CarNumber<<endl;cout<<"月份:"<<temp.Month<<endl;cout<<"应发工资:"<<temp.SPWages<<endl;cout<<"水费:"<<temp.Water<<endl;cout<<"电费:"<<temp.Electrical<<endl;cout<<"税金:"<<temp.Tax<<endl;cout<<"实发工资:"<<temp.APWages<<endl;cout<<endl;}FileClose(FP);}//////////////////////////////////////////////////void Statistics() //统计工资信息{Staff temp;char nametemp[10];float sum=0;int monthstart=0,monthover=0;cout<<"请输入统计的人员姓名:"<<endl;cin>>nametemp;cout<<"请输入统计时间段的起始月份(如:3)";cin>>monthstart;cout<<"请输入统计时间段的终止月份(如:3)";cin>>monthover;FP=FileOpen(FILENAME);while(fread(&temp,sizeof(Staff),1,FP)==1){if(strcmp(,nametemp)==0){if(temp.Month>=monthstart&&temp.Month<=monthover){sum=sum+temp.APWages;}}}cout<<"职工"<<nametemp<<"从"<<monthstart<<"月至"<<monthover<<"月合计"<<sum<<"元。

C语言编程---火车订票系统源代码之欧阳歌谷创作

欧阳歌谷创编 2021年2月1 欧阳歌谷创编 2021年2月1 火车订票系统源码

欧阳歌谷(2021.02.01) #include #include #include #include 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*/ 欧阳歌谷创编 2021年2月1 欧阳歌谷创编 2021年2月1 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("********************************************************"); 欧阳歌谷创编 2021年2月1 欧阳歌谷创编 2021年2月1 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)"); 欧阳歌谷创编 2021年2月1 欧阳歌谷创编 2021年2月1 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); 欧阳歌谷创编 2021年2月1 欧阳歌谷创编 2021年2月1 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) 欧阳歌谷创编 2021年2月1 欧阳歌谷创编 2021年2月1 { 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) 欧阳歌谷创编 2021年2月1 欧阳歌谷创编 2021年2月1 { 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 { 欧阳歌谷创编 2021年2月1 欧阳歌谷创编 2021年2月1 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) {

列车时刻管理系统C语言程序设计(源代码)

一、问题分析随着社会的不断发展,人们在交通方式的选择上有了不同以往的选择,以前的靠人力,畜力,以及摩托车,现在人们的选择更多的会放在了汽车,飞机还有列车上。

每当春节前后时,都有一批民工潮,学生潮,这些农民工和学生都来自于祖国的各个地方,因此车站如何合理有序的安排列车出站到站时间成了一个很关键的内容,有助于维持车站的秩序以及减少不必要的等待.而本课题的列车时刻管理系统也应用与这些地方,不过由于专业知识学的还不多,因此还不能将一个完整的列车时刻管理系统完全的展示出来,只是在最基础的层面上做了一些工作。

二、系统功能设计1.添加新记录:利用结构数组的方式来添加新记录,并且保存在文件train。

txt文件中,并且记录上限为300,新纪录的内容包括:出站地址,出站的时刻(时),出站时刻(分),到站地址,到站时刻(时),到站时刻(分)。

2.查看:查询功能总共分为四种方式:①按出站地址查询②按出站时刻查询③按到站地址查询④按到站时刻查询,这个功能由于能力有限,只限查找单一数据。

3.修改:修改功能:根据出站的地址,查找出对应的一组数据的内容,然后逐一修改.4.删除:修改功能总共分为两个部分:①单一删除(按照出站地址)②全部删除5.保存:每执行一个任务后程序会自动将数据写入train.txt文档中。

三、模块(函数)划分voidmain():主函数voidMainMenu():主菜单列表voidShowMenu():查询菜单列表void AddNew():添加新的数据intIsLoop():循环输入数据void Display():输出所有的函数void Search_ccity():按出站地址查询void Search_dcity():按到站地址查询void Search_ctime():按出站时刻查询voidSearch_dtime():按到站时刻查询void ChkData(char city1[],char city2[],int hour1,intminute1,int hour 2,int minute2):数据检测voidRecord_Modify():修改数据void DeleteMenu():删除菜单列表void DeleteOne():删除一组数据void DeleteAll():删除所有数据voidReadFromFile():从文件中读入voidWriteToFile():从文件中写入四、模块的算法设计(部分主要函数的代码)1.整体构造:2.结构体:struct Record{inthour1;inthour2;int minute1;ﻩintminute2;ﻩchar city1[20];char city2[20];};3.主菜单:void MainMenu(){ﻩsystem(”cls");printf(”———-————-—-——-—--———-—-—主菜单——-——---------——————-—-—-—-——\n”);ﻩint option;ﻩprintf("—--———-—-—-——--———-—-1-添加新记录—-——----——---——----—-—-——-\n”);printf(”-—-—-—-——————-----—-—2—查看-------———--------———-—----——---\n");ﻩprintf(”----—————————-—-—-——-3—修改-—-——---—------————-----——--—---\n");printf(”-———--——————————-—---4-删除-——-——--——--—-—--———-——-——----——\n");ﻩprintf("-—--———-------———---—5—退出程序—-————-————-—---——--—---——--\n");ﻩprintf(”请选择: \n”);scanf(”%d",&option);getchar();ﻩswitch(option)ﻩ{ﻩcase 1:AddNew();break;ﻩcase2:ShowMenu();break;case3:Record_Modify();break;ﻩcase 4:DeleteMenu();break;case 5:exit(0);ﻩ}}4.数据检测:voidChkData(charcity1[],char city2[],int hour1,int minute1,int hour2,int minute2){if (strlen(city1)>20)ﻩ{ﻩprintf(”出站地址的字符不能超过20个!\n”);ﻩﻩMainMenu();}ﻩif (strlen(city2)〉20){printf(”到站地址不能超过20位!\n");ﻩMainMenu();}ﻩif (hour1〈0||hour1〉23){printf("时刻输入错误(0〈=hour<24)!\n");ﻩMainMenu();}if(hour2〈0||hour2〉24)ﻩ{ﻩprintf(”时刻输入错误(0〈=hour〈24)!\n");MainMenu();}ﻩif(minute1〈0||minute1〉59){printf(”时刻输入错误(0<=minute<59)!\n");ﻩMainMenu();ﻩ}if(minute2<0||minute2〉59){ﻩprintf(”时刻输入错误(0〈=minute<59)!\n");MainMenu();ﻩ}}5.读入文件中的数据:voidReadFromFile(){FILE *fp;int i;if ((fp=fopen("train。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include#include/*时间库函数*/#include/*调用系统函数*/#include/*串操作及内存操作函数*/#include#include#defineN80/*宏定义多条记录*/voidmaipiao(ints,intt);/*函数定义*/floattimes(intk);inthour(intk){switch(k){case1:return07;break;case2:return10;break;case3:return13;break;case4:return16;break;case5:return19;break;case6:return21;break;/*d到闽清一天的发车时间小时段*/case7:return07;break;case8:return11;break;case9:return15;break;case10:return19;break;case11:return23;break;/*d到长乐一天的发车时间小时段*/case12:return07;break;case13:return11;break;case14:return15;break;case15:return19;break;case16:return23;break;/*d到连江一天的发车时间小时段*/case17:return07;break;case18:return11;break;case19:return16;break;case20:return20;break;/*d到永泰一天的发车时间小时段*/case21:return07;break;case22:return12;break;case23:return17;break;case24:return22;break;/*d到福清一天的发车时间小时段*/case25:return07;break;case26:return14;break;case27:return19;break;case28:return22;break;/*d到罗源一天的发车时间小时段*/}}/*开车时间段*/intminute(intk){switch(k){case1:return00;break;case2:return00;break;case3:return00;break;case4:return00;break;case5:return00;break;case6:return00;break;/*d到闽清一天的发车时间分钟段*/case7:return00;break;case8:return00;break;case9:return00;break;case10:return00;break;case11:return00;break;/*d到长乐一天的发车时间分钟段*/case12:return00;break;case13:return00;break;case14:return00;break;case15:return00;break;case16:return00;break;/*d到连江一天的发车时间分钟段*/case17:return00;break;case18:return30;break;case19:return00;break;case20:return30;break;/*d到永泰一天的发车时间分钟段*/case21:return00;break;case22:return30;break;case23:return00;break;case24:return30;break;/*d到福清一天的发车时间分钟段*/case25:return30;break;case26:return00;break;case27:return30;break;case28:return30;break;/*d到罗源一天的发车时间分钟段*/}}/*开车时间段*/voidwap(intk){switch(k){case1:printf("闽清");break;case2:printf("长乐");break;case3:printf("连江");break;case4:printf("永泰");break;case5:printf("福清");break;case6:printf("罗源");break;}}/*输入终点站的函数*/intshijian(){structtm*ptr;time_tlt;lt=time(NULL);ptr=gmtime(<);printf(ctime(<));return0;}/*输出当前时间的函数*/floattimes(intk){floatt;if(k==1)t=1.5;if(k==2)t=3.0;if(k==3||k==4)t=4.0;if(k==5||k==6)t=4.5;returnt;}/*输入行车时间的函数*/intnumber(intk){intf;if(k==1||k==2)f=30;if(k==3||k==4)f=40;if(k==5||k==6)f=45;returnf;}/*输入最大载客量的函数*/intnownumber(intk,inti){intn=0;charfilename[10];switch(i){case1:strcpy(filename,"qiu1.txt");break;case2:strcpy(filename,"qiu2.txt");break;case3:strcpy(filename,"qiu3.txt");break;case4:strcpy(filename,"qiu4.txt");break;case5:strcpy(filename,"qiu5.txt");break;case6:strcpy(filename,"qiu6.txt");break;case7:strcpy(filename,"qiu7.txt");break;case8:strcpy(filename,"qiu8.txt");break;case9:strcpy(filename,"qiu9.txt");break;case10:strcpy(filename,"qiu10.txt");break;case11:strcpy(filename,"qiu11.txt");break;case12:strcpy(filename,"qiu12.txt");break;case13:strcpy(filename,"qiu13.txt");break;case14:strcpy(filename,"qiu14.txt");break;case15:strcpy(filename,"qiu15.txt");break;case16:strcpy(filename,"qiu16.txt");break;case17:strcpy(filename,"qiu17.txt");break;case18:strcpy(filename,"qiu18.txt");break;case19:strcpy(filename,"qiu19.txt");break;case20:strcpy(filename,"qiu20.txt");break;case21:strcpy(filename,"qiu21.txt");break;case22:strcpy(filename,"qiu22.txt");break;case23:strcpy(filename,"qiu23.txt");break;case24:strcpy(filename,"qiu24.txt");break;case25:strcpy(filename,"qiu25.txt");break;case26:strcpy(filename,"qiu26.txt");break;case27:strcpy(filename,"qiu27.txt");break;case28:strcpy(filename,"qiu28.txt");break;case29:strcpy(filename,"qiu29.txt");break;}FILE*fp;if((fp=fopen(filename,"rt+"))==NULL){printf("cannotopenfile,strikeanykeyexit!");exit(1);}fscanf(fp,"%d",&n);n=n+k;rewind(fp);fprintf(fp,"%d",n);//将输入数组里面的数据写到文本里fclose(fp);returnn;}/*现在已定票人数*/inttangci(intk){

相关文档
最新文档