资源预览内容
第1页 / 共12页
第2页 / 共12页
第3页 / 共12页
第4页 / 共12页
第5页 / 共12页
第6页 / 共12页
第7页 / 共12页
第8页 / 共12页
第9页 / 共12页
第10页 / 共12页
亲,该文档总共12页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
火车站售票查询系统:#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*/ 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 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 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) break ; /*判断是否已经存在*/ 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 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: %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); 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(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 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 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
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号