- 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
您可能关注的文档
最近下载
- inspector辐射测量仪操作规程.doc VIP
- INSPECTOR射线仪手则.doc VIP
- (一模)2026年合肥市2026届高三第一次教学质量检测 地理试卷(含官方答案).docx
- (一模)2026年合肥市2026届高三第一次教学质量检测 数学试卷(含官方答案).pdf
- (一模)2026年合肥市2026届高三第一次教学质量检测 英语试卷(含官方答案).docx
- 放射性仪器和测量.ppt VIP
- 【高清可复制】11ZJ401 楼梯栏杆(1).pdf VIP
- 11ZJ311 《地下室防水》建筑标准.docx VIP
- RAM SURF-1操作手册.pdf VIP
- 2025年度组织生活会会前谈心谈话记录(支部书记与支部委员谈心谈话、支部委员之间谈心谈话、支部委员与联系党员谈心谈话、党员与党员谈心谈话、上级党组织负责人与支部书记谈心谈话).docx VIP
原创力文档

文档评论(0)