c语言火车票管理系统基本代码

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

#include

#include

#include

#include

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];

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;

}

}

相关文档
最新文档