数据结构课程设计航空客运订票系统.docx

上传人:b****7 文档编号:15423464 上传时间:2023-07-04 格式:DOCX 页数:26 大小:96.93KB
下载 相关 举报
数据结构课程设计航空客运订票系统.docx_第1页
第1页 / 共26页
数据结构课程设计航空客运订票系统.docx_第2页
第2页 / 共26页
数据结构课程设计航空客运订票系统.docx_第3页
第3页 / 共26页
数据结构课程设计航空客运订票系统.docx_第4页
第4页 / 共26页
数据结构课程设计航空客运订票系统.docx_第5页
第5页 / 共26页
数据结构课程设计航空客运订票系统.docx_第6页
第6页 / 共26页
数据结构课程设计航空客运订票系统.docx_第7页
第7页 / 共26页
数据结构课程设计航空客运订票系统.docx_第8页
第8页 / 共26页
数据结构课程设计航空客运订票系统.docx_第9页
第9页 / 共26页
数据结构课程设计航空客运订票系统.docx_第10页
第10页 / 共26页
数据结构课程设计航空客运订票系统.docx_第11页
第11页 / 共26页
数据结构课程设计航空客运订票系统.docx_第12页
第12页 / 共26页
数据结构课程设计航空客运订票系统.docx_第13页
第13页 / 共26页
数据结构课程设计航空客运订票系统.docx_第14页
第14页 / 共26页
数据结构课程设计航空客运订票系统.docx_第15页
第15页 / 共26页
数据结构课程设计航空客运订票系统.docx_第16页
第16页 / 共26页
数据结构课程设计航空客运订票系统.docx_第17页
第17页 / 共26页
数据结构课程设计航空客运订票系统.docx_第18页
第18页 / 共26页
数据结构课程设计航空客运订票系统.docx_第19页
第19页 / 共26页
数据结构课程设计航空客运订票系统.docx_第20页
第20页 / 共26页
亲,该文档总共26页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

数据结构课程设计航空客运订票系统.docx

《数据结构课程设计航空客运订票系统.docx》由会员分享,可在线阅读,更多相关《数据结构课程设计航空客运订票系统.docx(26页珍藏版)》请在冰点文库上搜索。

数据结构课程设计航空客运订票系统.docx

数据结构课程设计航空客运订票系统

#include#include#include#include#include#include#defineMAX60#defineNULL0

typedefstructCustomer

{

charName[8];

intAmount;

charRank;

intIDinfor;

structCustomer*Next;

}Customer;

/*乘客信息*/

/*姓名*/

/*定票数*/

/*舱位等级*/

/*个人信息*/

/*指向下一乘客结点*/

typedefstructFlight

{

charDes_Name[10];charFlight_No[6];

charPlane_No[6];intWeek_Day;

intCustomer_Amount;intFree_Amount;

intPrice[3];

Customer*CustName;

Customer*ReplName;structFlight*Next;

}Flight,*PFlight;

/*航线信息*/

/*终点站名*/

/*航班号*/

/*飞机号*/

/*飞行周日*/

/*乘员定额*/

/*剩余票数*/

/*舱位等级的价格*/

/*该航班的已定票乘客名单*/

/*该航班的候补乘客名单*/

/*指示下一航线结点*/

intCustomer_Count=0;

Flight*Head;

Flight*p2;

Customer*Custp1[MAX];

/*所有航线的定票乘客总数*/

/*航线头指针*/

/*航线结点指针*/

/*各条航线乘客结点指针*/

/*是否有定票乘客*/

/*是否有候补乘客*/

/*满足要求的定票乘客的前结点,以作删除操作*/

Customer*Replp1[MAX];intIsEmpty=1;

intIsReplace=1;

Customer*prior;

intshouldsave=0;

/*各条航线候补结点指针*/

 

/*询问是否继续的函数*/

charContinue()

{

charanswer;

while

(1)

{

printf("\n\t您是否想继续(Y/N)?

");scanf("%s",&answer);

system("cls");if(answer=='y'||answer=='Y')return'y';

elseif(answer=='n'||answer=='N')

return'n';

else

printf("\n\t输入有误,请重新输入!

");

}

}

/*操作出错函数*/

voidErrorMess()

{

printf("\n\t对不起,您的操作有误!

");getch();

}

/*系统退出函数*/

intExitSystem()

{

charanswer;

printf("\n\t您是否想要退出系统(Y/N)?

");scanf("%s",&answer);if(answer=='y'||answer=='Y')

return1;

else

return0;

/*航线查找函数*/

/*Find_Line()为重载函数*/

intFind_Line(PFlightL,char*key)/*核对航线是否唯一*/

{

intflag=0;/*该标志位0表示未找到相关信息,反之即找到,以下标志位同理*/

Flight*p1;

p1=L;/*赋航线首地址*/

if(p1==p2)/*首航线不作比较*/

returnflag;

while(p1!

=p2&&p1!

=NULL)/*本航班号不纳入比较范围,否则会一直提示航线不唯一*/

{if(strcmp(p1->Flight_No,key)==0)

{

flag=1;

break;

}p1=p1->Next;/*指向下一航班结点*/

}

returnflag;

}

intFind_Line(PFlightL,char*key,PFlight&p2,int&Flight_No)/*航线查找函数*/{

intflag=0;/*该标志位0表示未找到相关信息,反之即找到*/

Flight*p1;

p1=L;/*赋航线首结点*/while(p1!

=NULL)

{if(strcmp(p1->Flight_No,key)==0)/*不包括当前航线*/{

flag=1;

p2=p1;

break;

}

p1=p1->Next;/*指向下一航班结点*/if(p1!

=NULL)/*遇结束符不作统计范围*/

Flight_No++;

}

returnflag;

 

/*航班查找函数*/

voidLine_search()

{

Flight*p1;

p1=Head;

charDesname[50];//查询终点站航班关键字

if(Head==NULL)

{

printf("\n\t没有到达您想要的终点站的航班!

");

getch();

return;

}

printf("\n\t请输入终点站名:

");

scanf("%s",Desname);

printf("\n\t您所查询的航班的信息:

\n");

printf("\n

\n");

while(p1!

=NULL)

{

if(strcmp(p1->Des_Name,Desname)==0)

{

Free_Num

printf("Des_NameFlight_NoPlane_NoWeek_DayCust_Num1_Price2_Price3_Price\n");

printf("\n%-9s%-10s%-9s%-9d%-9d%-9d%-8d%-8d%-8d",p1->Des_Name,p1->Flight_No,p1->Plane_No,p1->Week_Day,

p1->Customer_Amount,p1->Free_Amount,p1->Price[0],p1->Price[1],p1->Price[2])

J

}p1=p1->Next;

}

printf("\n

\n");

Continue();

}

/*航线添加函数*/

voidLine_Add()

{

Flight*p1;/*建立临时航线结点*/while

(1)

{

if(Head==NULL)/*航线为空*/

{p1=p2=newFlight;/*建立首个航线*/Head=p2;

}

else

{p1=newFlight;/*建立航线结点*/

p2->Next=p1;/*前一航线结点指向当前航班结点*/p2=p1;/*保留当前航班结点地址*/

}

printf("\n\t添加新的航线!

\n");

printf("\n\t请输入终点站名:

");

scanf("%s",&p2->Des_Name);

while

(1)/*数据合法性检验*/

{printf("\n\t请输入唯一的航班号:

");scanf("%s",&p2->Flight_No);if(Find_Line(Head,p2->Flight_No))/*存在航班号*/printf("\n\t航班号已经存在!

\n");

elsebreak;

}

printf("\n\t请输入飞机号:

");scanf("%s",&p2->Plane_No);

while

(1)

{

printf("\n\t请输入航班日期(请输入1—7):

");scanf("%d",&p2->Week_Day);if(p2->Week_Day<1||p2->Week_Day>7)

printf("\n\t输入日期有误,请重新输入!

\n");else

break;

}

printf("\n\t请输入座位数量:

");scanf("%d",&p2->Customer_Amount);

printf("\n\t请输入头等舱的价钱:

");

scanf("%d",&p2->Price[0]);

printf("\n\t请输入二等舱的价钱:

");

scanf("%d",&p2->Price[1]);

printf("\n\t请输入三等舱的价钱:

");

/*剩余票数与乘员定额相同*/

/*该航线定票乘客头指针为空*/

/*初始候补名单为空*/

/*航线的下一结点为空*/

scanf("%d",&p2->Price[2]);

p2->Free_Amount=p2->Customer_Amount;

p2->CustName=NULL;

p2->ReplName=NULL;

shouldsave=1;

if(Continue()=='n')

{

p2->Next=NULL;

return;

}

}

}

/*航线是否为空函数*/

intEmpty_Flight()

{

if(Head==NULL)

{

system("cls");

printf("\n\t对不起,航线不存在,按任意键返回!

");getch();

return1;

}

else

return0;

}

/*航线查看函数*/

voidLine_See()

{

system("cls");

Flight*p1;

p1=Head;

if(Empty_Flight())/*航班线为空*/

return;

printf("\n\n\t航班信息:

\n");

printf("\n

\n");

printf("Des_NameFlight_NoPlane_NoWeek_DayCust_NumFree_Num1_Price2_Price3_Price\n");

while(p1!

=NULL)

{

printf("\n%-9s%-10s%-9s%-9d%-9d%-9d%-8d%-8d%-8d",p1->Des_Name,p1->Flight_No,p1->Plane_No,p1->Week_Day,

p1->Customer_Amount,p1->Free_Amount,p1->Price[0],p1->Price[1],p1->Price[2]);

p1=p1->Next;

}

printf("\n

\n");

printf("\n\t按任意键返回!

\n");

getch();

}

/*航线管理菜单*/

voidLinemanageMenu()

{

charc;

system("cls");

while

(1)

{

printf("\n\t\t

航线管理菜单:

");

printf("\n

\n\n");

printf("\t1.

添加新的航线\n");

printf("\t2.

查询航线\n");

printf("\t3.

查看航线\n");

printf("\t4.

返回主菜单\n");

printf("\n

\n");

printf("\t

请选择您想要的服务:

");

scanf("%s",&c);

switch(c)

{

case'1':

Line_Add();break;

case'2':

Line_search();break;

case'3':

Line_See();break;

case'4':

return;}

}

}

/*订票办理函数*/voidbookingMenu()

{

intTicket_Count,IDinfor,i,flag=0;

intFlight_No=0;/*记录满足条件的航线的定票结点*/

Flight*p1;/*记下满足条件的航线结点地址*/

Customer*p2;

Customer*p3;charanswer[7];chartemp;charc;

inttag=0;intIsRepl=0;if(Empty_Flight())

/*临时性定票乘员结点*//*临时性候补乘员结点*//*用户输入的航班数据*/

/*候补乘客标志位*/

/*是否执行候补操作标志位*/

/*航班线为空*/

return;

while

(1){

printf("\n\t现在您可以订票!

");

flag=0;/*标志位清零以重新作出判断*/Flight_No=0;

tag=0;

printf("\n\t请输入航线号:

");scanf("%s",&answer);

以下操作*/

{while

(1)/*数据合法性检验*/{

printf("\n\t请输入您想要订购的票的数量:

");scanf("%d",&Ticket_Count);

if(Ticket_Count==0)

{

printf("\n\t请再次输入飞机号:

\n");

getch();

 

else

break;

}

p1->CustName=Custp1[Flight_No];

}

else/*建立该航线的后续乘客结点*/

{

p2=newCustomer;Custp1[Flight_No]->Next=p2;Custp1[Flight_No]=p2;

}

IsEmpty=0;/*定票乘员不为空*/Custp1[Flight_No]->Amount=Ticket_Count;/*订票数*/IDinfor=p1->Customer_Amount-p1->Free_Amount+1;/*算出座位号*/

Custp1[Flight_No]->IDinfor=IDinfor;/*赋座位号*/

p1->Free_Amount-=Ticket_Count;/*减去定票数*/

printf("\n\t请输入您的姓名:

");scanf("%s",&Custp1[Flight_No]->Name);

while

(1)/*数据合法性检验*/{

printf("\n\t请输入舱位等级:

");scanf("%s",&Custp1[Flight_No]->Rank);

if(!

(Custp1[Flight_No]->Rank>='1'&&Custp1[Flight_No]->Rank<='3'))

{

printf("\n\t输入有误,请重新输入!

");

getch();

}

else

break;

}

printf("\n\t请输入您的ID信息:

");

scanf("%d",&Custp1[Flight_No]->IDinfor);

if(Ticket_Count<10)/*为显示规整,作相应处理*/printf("\n\t");

else

printf("\n\t");

printf("\n\t恭喜您订票成功!

\n");

for(i=1;i<=Ticket_Count;i++)/*打印座位号*/

{

printf("\n\t您所预定的座位号是%d",IDinfor++);

if(i%10==0)

printf("\n\t");

}

printf("\n");

}/*满足定票数*/

elseif(p1->Free_Amount==0)

{

printf("\n\t对不起,票已售完!

\n");

IsRepl=0;

}

else

{

printf("\n\t对不起,当前没有多余的票!

\n");

IsRepl=0;

}

if(!

IsRepl)

{

printf("\n\t您是否想成为候补乘客(Y/N)?

");

scanf("%s",&temp);

if(temp=='y'||temp=='Y')/*以下为候补操作*/

{

if(p1->ReplName==NULL)

{

Replp1[Flight_No]=p3=newCustomer;/*建立该航线的首位候补乘客结点*/

p1->ReplName=Replp1[Flight_No];

}

else

{

p3=newCustomer;

Replp1[Flight_No]->Next=p3;

Replp1[Flight_No]=p3;

}

IsReplace=0;/*候补乘客不为空*/

tag=1;/*已选择列入候补乘客名单*/

Replp1[Flight_No]->Amount=Ticket_Count;

printf("\n\t请输入您的姓名:

");

scanf("%s",&Replp1[Flight_No]->Name);

Replp1[Flight_No]->IDinfor=IDinfor;/*候补乘客的座位*/

Replp1[Flight_No]->Amount=Ticket_Count;/*候补乘客的订票数*/

while

(1)/*数据合法性检验*/

{

printf("\n\t请输入舱位等级:

");scanf("%s",&Replp1[Flight_No]->Rank);printf("\n\t请输入您的ID信息:

");scanf("%d",&Replp1[Flight_No]->IDinfor);

if(!

(Replp1[Flight_No]->Rank>='1'&&Replp1[Flight_No]->Rank<='3'))

{

printf("\n\t输入有误,请重新输入.");

getch();

}

else

break;

}

printf("\n\t没有剩余座位!

\n");/*候补乘客无座提示*/

shouldsave=1;

}/*进入候补名单*/

}/*票数满足*/

}/*航线存在*/

else

printf("\n\t对不起,航线不存在!

\n");/*航线不存在*/

if(flag)/*此处不作处理,则会地址溢出*/

Custp1[Flight_No]->Next=NULL;/*末位定票乘客的指针置空*/

if(tag)

{

Replp1[Flight_No]->Next=NULL;/*末位候补乘客的指针置空*/

printf("\n\t您已经成功排入候补订票队列中!

\n");

}

printf("\n\t是否退出菜单?

:

(y/n)");

scanf("%s",&c);

if(c=='y')

return;

}/*while*/

/*订票乘客信息*/

voidDisplay_Reserve()

{

system("cls");

Flight*p1;

Customer*p2;

p1=Head;

if(Empty_Flight())

return;

printf("\n\t订票乘客信息");

if(IsEmpty)

{

printf("\n\t对不起,没有订票乘客信息!

\n");getch();

return;

}

printf("\n

\n");

ID\n");

printf("NameFlight_NoPlane_NoTic_AmountDes_NameRank_No

while(p1!

=NULL)

{if(p1->CustName!

=NULL)

{p2=p1->CustName;while(p2!

=NULL)

{

printf("\n%-8s%-10s%-9s%-11d%-9s%-9c%-9d",p2->Name,p1->Flight_No,p1->Plane_No,p2->Amount,p1->Des_Name,p2->Rank,p2->IDinfor);

if(p1->Free_Amount>=1)printf("\n\n\t还有多余的票!

\n");

else

printf("\n\n\t票已售完!

\n");p2=p2->Next;

}}p1=p1->Next;

printf("\n\n

\n");

printf("\n\t按任意键返回!

");getch();

return;

/*候补乘客信息*/

voidDisplay_Replace()

{

system("cls");

Flight*p1;

Customer*p2;

p1=Head;

if(Empty_Flight())

return;

printf("\n\t候补乘客信息!

");

if(IsReplace)

{

printf("\n\t对不起,没有候补乘客!

\n");

getch();

return;

}

printf("\n

\n");

ID\n");

printf("NameFlight_NoPlane_NoTic_AmountDes_NameRank_Nowhile(p1!

=NULL)

{

if(p1->ReplName!

=NULL)

{

p2=p1->ReplName;

while(p2!

=NULL)

{

printf("\n%-8s%-10s%-9s%-11d%-9s%-9c%-9d",p2->Name,p1->Flight_No,p1->Plane_No,p2->Amount,p1->Des_Name,p2->Rank,p2->IDinfor);

if(p1->Free_Amount>=1)

printf("\n\t还有多余的票!

\n");

else

printf("\n\t票已售完!

\n");

p2=p2->Next;

}p1=p1->Next;

}

printf("\n\n

\n");

printf("\n\t按任意键返回!

");

getch();

return;

}

/*退票办理函数*/

printf("\n\t现在开始进行退票手续");

if(IsEmpty)

{

printf("\n\t对不起,乘客不存在!

");getch();

return;

}

while

(1)

{

flag=0;

tag=0;

Flight_No=0;

printf("\n\t请输入航线:

");

/*航线存在*/

scanf("%s",&answer);if(Find_Line(Head,answer,p1

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2