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

上传人:F****n 文档编号:102705268 上传时间:2019-10-04 格式:DOC 页数:12 大小:44KB
返回 下载 相关 举报
c语言程序--火车站售票系统程序_第1页
第1页 / 共12页
c语言程序--火车站售票系统程序_第2页
第2页 / 共12页
c语言程序--火车站售票系统程序_第3页
第3页 / 共12页
c语言程序--火车站售票系统程序_第4页
第4页 / 共12页
c语言程序--火车站售票系统程序_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《c语言程序--火车站售票系统程序》由会员分享,可在线阅读,更多相关《c语言程序--火车站售票系统程序(12页珍藏版)》请在金锄头文库上搜索。

1、火车站售票查询系统:#include #include #include #include int shoudsave=0 ;int count1=0,count2=0,mark=0,mark1=0 ;/*定义存储火车信息的结构体*/struct train char num10;/*列车号*/ char city10;/*目的城市*/ char takeoffTime10;/*发车时间*/ char receiveTime10;/*到达时间*/ int price;/*票价*/ int bookNum ;/*票数*/;/*订票人的信息*/struct man char num10;/*ID*

2、/ char name10;/*姓名*/ 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 sys

3、tem 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 informatio

4、n to file *); puts(* 7:quit the system *); puts(*);/*添加一个火车信息*/void InsertTraininfo(Link linkhead) struct node *p,*r,*s ; char num10; 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) b

5、reak ; /*判断是否已经存在*/ while(s) if(strcmp(s-data.num,num)=0) printf(the train %shas 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 tr

6、ain 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

7、= 1 ; /*打印火车票信息*/void printTrainInfo(struct node*p) puts(nThe following is the record you want:); printf(number of train: %sn,p-data.num); printf(city the train will reach: %sn,p-data.city); printf(the time the train take off: %snthe time the train reach: %sn,p-data.takeoffTime,p-data.receiveTime);

8、printf(the price of the ticket: %dn,p-data.price); printf(the number of booked tickets: %dn,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(numor

9、city,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 str15,str210; if(!l-next) printf(There is not any record !); return ; printf(Choose the way:n1:according to the number of train;n2:according

10、 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 cant 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 cant be found!); /*订票子模块*/void BookTicket(Link l,bookManLink k) Node*r10,*p ; char ch,dem ; bookMan*v,*h ; int i=0,t=0 ; char str10,st

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

当前位置:首页 > 办公文档 > 教学/培训

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