火车订票系统源码
#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*/
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(\scanf(\
if(strcmp(num,\break ;
/*判断是否已经存在*/ while(s) {
if(strcmp(s->data.num,num)==0) {
printf(\return ;
}
s = s->next ; }
p = (struct node*)malloc(sizeof(struct node)); strcpy(p->data.num,num);
printf(\scanf(\
printf(\scanf(\
printf(\scanf(\printf(\scanf(\
printf(\scanf(\p->next=NULL ; r->next=p ; r=p ; shoudsave = 1 ; } }
/*打印火车票信息*/
voidprintTrainInfo(struct node*p) {
puts(\printf(\
printf(\
printf(\reach: %s\\n\printf(\ %d\\n\
printf(\ booked tickets: %d\\n\}
struct node * Locate1(Link l,charfindmess[],char numorcity[]) {
Node*r ;
if(strcmp(numorcity,\ {
r=l->next ; while(r) {
if(strcmp(r->data.num,findmess)==0) return r ;
r=r->next ; } }
else if(strcmp(numorcity,\ {
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(\return ; }
printf(\the city:\\n\scanf(\if(sel==1) {
printf(\scanf(\
p=Locate1(l,str1,\if(p)
{
printTrainInfo(p); } else
{
mark1=1 ;
printf(\ } }
else if(sel==2) {
printf(\scanf(\
p=Locate1(l,str2,\if(p)
{
printTrainInfo(p); } else
{
mark1=1 ;

