飞机订票系统Word格式文档下载.docx
- 文档编号:17199445
- 上传时间:2022-11-28
- 格式:DOCX
- 页数:14
- 大小:17.02KB
飞机订票系统Word格式文档下载.docx
《飞机订票系统Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《飞机订票系统Word格式文档下载.docx(14页珍藏版)》请在冰豆网上搜索。
"
scanf("
%d"
&
n);
printf("
switch(n)
{
case1:
lurugongneng();
break;
case2:
search();
case3:
dingpiaogongneng();
case4:
tuipiaogongneng();
default:
exit(0);
}
}while(n==1||n==2||n==3||n==4);
return0;
}
声明函数
typedefstructYidingmingdan{
charname[15];
intdingpiaoshu;
structYidingmingdan*next1;
}Yidingmingdan,*Link;
typedefstructHoubukehu{
intyudingpiao;
structHoubukehu*next2;
}Houbukehu,*queue;
typedefstruct{
queuefront;
queuerear;
}linkqueue;
typedefstructHangxian{
charhangbanhao[15];
charfeijihao[15];
intfeixingriqi;
intchenkerenshu;
intyupiaoshu;
charzhongdianzhan[15];
structHangxian*next;
structYidingmingdan*yiding;
structHoubukehu*yudingkehu;
}Hangxian,*Linklist;
voidhbhchaxun();
voidmddchaxun();
voidlurugongneng();
voidsearch();
voiddingpiaogongneng();
voidtuipiaogongneng();
LinklistInitLinklist();
intInsertLinklist(Linklist&
head1);
调用函数
structHangxian*L=NULL;
structYidingmingdan*H;
linkqueueQ;
voidlurugongneng()
intj=1,m;
do
{
InsertLinklist((Linklist)L);
是否要输入下一个航线记录?
是请输入1\n"
否请输入2\n"
m);
}while(m==1);
LinklistInitLinklist()
L=(Linklist)malloc(sizeof(Hangxian));
L->
next=NULL;
return(L);
L)
{
Linklistp;
p=(Linklist)malloc(sizeof(Hangxian));
printf("
请依次输入下面几项内容:
\n\n"
航班号\n"
gets(p->
hangbanhao);
飞机号\n"
feijihao);
终点站\n"
zhongdianzhan);
飞行日期\n"
scanf("
p->
feixingriqi);
乘客总数\n"
chenkerenshu);
余票数\n"
yupiaoshu);
p->
yiding=(structYidingmingdan*)malloc(sizeof(Yidingmingdan));
yudingkehu=Q.front=Q.rear=(queue)malloc(sizeof(Houbukehu));
if(L==0)
{L=p;
else
next=L->
next;
next=p;
return
(1);
voidsearch()
查找航线信息\n"
1.通过目的地查询\n"
2.通过航班号查询\n"
++++++++++++++++++++++++\n"
switch(n)
case1:
mddchaxun();
break;
case2:
hbhchaxun();
default:
break;
}
voidmddchaxun()
charc[15];
intm;
Linklistp=L;
请输入要查询的目的地:
gets(c);
p=p->
if(p)
m=strcmp((*p).zhongdianzhan,c);
if(m==0)
{
printf("
航班信息:
航班号:
%s\n"
p->
飞机号:
飞行时间(星期):
%d\n"
余票量:
}
else
对不起没有你要找的目的地:
}
m=0;
}while(m!
=0);
voidhbhchaxun()
请输入要查询的航班号:
m=strcmp((*p).hangbanhao,c);
%d\n\n"
对不起没有你要找的航班号:
voiddingpiaogongneng()
H=(structYidingmingdan*)malloc(sizeof(Yidingmingdan));
Yidingmingdan*h=H,*h1;
linkqueueq=Q;
intm=1,piao,ydpiao=0,yd=0,n;
请输入终点站名:
p=L->
if(p)
do
m=strcmp(p->
zhongdianzhan,c);
if(m!
=0)
对不起,没有你要找的航班:
gotoloop1;
if(m==0)
elsep=p->
}while(m!
if(m==0)
printf("
\n请输入你要订的票数:
scanf("
piao);
if(piao<
=p->
yupiaoshu)
h=p->
yiding;
if(h)
{
h1=h;
h=h->
next1;
h=(structYidingmingdan*)malloc(sizeof(Yidingmingdan));
printf("
请输入你的名字:
gets(h->
name);
h->
dingpiaoshu=piao;
next1=h1->
h1->
next1=h;
p->
yupiaoshu=p->
yupiaoshu-piao;
订票成功:
m=2;
}
{
对不起,余票%d张不足,不能完成订票\n\n"
是否要重新订票?
需要请输入1否则请按2预订请输入3:
"
scanf("
if(m==3)gotoloop3;
}while(m==1);
elseif(!
p)
{
loop3:
structHoubukehu*q3;
对不起,该航班的票已售完\n"
q.front=p->
yudingkehu;
if(q.front==q.rear)
没有人预订票,是否要预订?
elseif(q.front!
=q.rear)
已有人预订票,是否要预订?
预订请输入1否则输入2:
if(n==1)
q3=(queue)malloc(sizeof(Houbukehu));
请输入你的姓名"
gets(q3->
gets(q3->
请输入订票数"
q3->
yudingpiao);
q3->
next2=NULL;
q.rear->
next2=q3;
q.rear=q3;
你已经预订了!
loop1:
;
voidtuipiaogongneng()
Yidingmingdan*h=H,*h1,*h2;
charc[15],name1[15];
intm=1,piao,n;
请输入航班号:
p=L;
if(!
p)
\n对不起,没有你要找的航班:
gotoloop1;
m=strcmp(p->
hangbanhao,c);
if(m==0)
航班信息:
周%d\n"
elsep=p->
if(m==0)
h=p->
if(h)
{
请输入你的姓名:
gets(name1);
gets(name1);
请输入你订的票数:
h1=h;
h=h->
if(strcmp(h->
name,name1)==0&
&
h->
dingpiaoshu==piao)
p->
yupiaoshu+=h->
dingpiaoshu;
h2=h;
h1->
next1=h->
free(h2);
你取消订票成功:
structHoubukehu*q3;
q.front=p->
if(q.front==q.rear)
{
printf("
没有人预订票:
gotoloop1;
}
if((p->
yupiaoshu)>
=(q.front->
next2->
yudingpiao))
h2=(structYidingmingdan*)malloc(sizeof(Yidingmingdan));
strcpy(h2->
name,q.front->
h2->
dingpiaoshu=q.front->
yudingpiao;
n=p->
yupiaoshu-q.front->
yupiaoshu=n;
q3=Q.front->
next2;
q.front->
next2=q3->
if(q.rear==q3)q.rear=q.front;
free(q3);
链队中删除成功\n"
h2->
next1=h2;
为预订的客户订票成功\n"
elseprintf("
余票数不够,不能为预订客户订票!
{
对不起,该航班没有人订票或者是你没有订该航班的票\n"
是否要重新查找并取消订票?
需要请输入1否则请按2"
loop1:
;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 飞机 订票 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)