c语言定订票系统.docxVIP

  • 1
  • 0
  • 约8.9千字
  • 约 16页
  • 2023-05-12 发布于上海
  • 举报
– – PAGE 11 – – – PAGE 14 – C 语言——订票系统 代 码 部 分 : #include conio.h #include stdio.h #include stdlib.h #include string.h #include dos.h #define HEADER1 TICKET \n #define HEADER2 | city|takeofftime|receivetime|price|ticketnumber|\n  number  BOOK |start city|reach #define HEADER3 ||||||| |\n #define FORMAT |%-10s|%-10s|%-10s|%-10s |%-10s |%5d| %5d |\n #define DATA p-data.num,p-data.startcity,p-data.reachcity,p-data.takeofftime,p-data.receivetime,p-data.pr ice,p-data.ticketnum int saveflag=0 ; /*定义存储火车信息的结构体*/ struct train { char num[10];/* 列车号*/ char startcity[10];/* 出发城市*/ char reachcity[10];/*目的城市*/ char takeofftime[10];/*发车时间*/ char receivetime[10];/*到达时间*/ int price;/*票价*/ int ticketnum ;/*票数*/ }; /*订票人的信息*/ struct man { char num[10];/*ID*/ char name[10];/*姓名*/ int bookNum ;/*订的票数*/ }; /*定义火车信息链表的结点结构*/ typedef struct node { struct train data ; struct node * next ; }Node,*Link ; /*定义订票人链表的结点结构*/ typedef struct Man { struct man data ; struct Man *next ; }book,*bookLink ; /* 初始界面*/ void menu() { puts(\n\n); puts(\t\t| |); puts(\t\t| Booking Tickets puts(\t\t| |); puts(\t\t| 0:quit the system puts(\t\t| 1:Insert a train information  |);  |); |); puts(\t\t| 2:Search a train information |); puts(\t\t| 3:Book a train ticket |); puts(\t\t| 4:Modify the train information |); puts(\t\t| 5:Show the train information |); puts(\t\t| 6:save information to file |); puts(\t\t| |); } /*添加一个火车信息*/ void Traininfo(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 %sis existing!\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 start:); scanf(%s,p-data.startcity);/*输入出发城市*/ pri

文档评论(0)

1亿VIP精品文档

相关文档