资源描述:
《c语言编程---火车订票系统源代码.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.火车订票系统源码#include#include#include#includeintshoudsave=0;intcount1=0,count2=0,mark=0,mark1=0;/*定义存储火车信息的结构体*/structtrain{charnum[10];/*列车号*/charcity[10];/*目的城市*/chartakeoffTime[10];/*发车时间*/charreceiveTime[10];/*到达时间*/intp
2、rice;/*票价*/intbookNum;/*票数*/};/*订票人的信息*/structman{charnum[10];/*ID*/..charname[10];/*姓名*/intbookNum;/*需求的票数*/};/*定义火车信息链表的结点结构*/typedefstructnode{structtraindata;structnode*next;}Node,*Link;/*定义订票人链表的结点结构*/typedefstructpeople{structmandata;structpeople*next;
3、}bookMan,*bookManLink;/*初始界面*/voidprintInterface(){puts("********************************************************");puts("*Welcometousethesystemofbookingtickets*");puts("********************************************************");puts("*Youcanchoosetheoperati
4、on:*");..puts("*1:Insertatraininformation*");puts("*2:Inquireatraininformation*");puts("*3:Bookatrainticket*");puts("*4:Updatethetraininformation*");puts("*5:Advicetoyouaboutthetrain*");puts("*6:saveinformationtofile*");puts("*7:quitthesystem*");puts("******
5、**************************************************");}/*添加一个火车信息*/voidInsertTraininfo(Linklinkhead){structnode*p,*r,*s;charnum[10];r=linkhead;s=linkhead->next;while(r->next!=NULL)r=r->next;while(1){printf("pleaseinputthenumberofthetrain(0-return)");scanf("%s
6、",num);..if(strcmp(num,"0")==0)break;/*判断是否已经存在*/while(s){if(strcmp(s->data.num,num)==0){printf("thetrain'%s'hasbeenborn!",num);return;}s=s->next;}p=(structnode*)malloc(sizeof(structnode));strcpy(p->data.num,num);printf("Inputthecitywherethetrainwillreach:
7、");scanf("%s",p->data.city);printf("Inputthetimewhichthetraintakeoff:");scanf("%s",p->data.takeoffTime);printf("Inputthetimewhichthetrainreceive:");scanf("%s",&p->data.receiveTime);printf("Inputthepriceofticket:");scanf("%d",&p->data.price);..printf("Inputth
8、enumberofbookedtickets:");scanf("%d",&p->data.bookNum);p->next=NULL;r->next=p;r=p;shoudsave=1;}}/*打印火车票信息*/voidprintTrainInfo(structnode*p){puts("Thefollowingistherecordyouwant:");printf(">>nu