




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第C语言实现飞机订票系统的完整代码puts("**********************************************************************");
puts("----------------------------------------------------------------------");
puts("choosethefollowoperation(0-8)");
puts("---------------------------------------------------------------------");
puts("*******************1flights********************");
puts("*******************2Origin********************");
puts("*******************3Destination********************");
puts("*******************4Takeofftime********************");
puts("*******************5Revercetime********************");
puts("*******************6Prices********************");
puts("*******************7Disscount********************");
puts("*******************8ticketnumber********************");
puts("*******************0quits********************");
puts("**********************************************************************");
voidModify(PPlaneNodepstPlaneNodeHead)
assert(pstPlaneNodeHead!=NULL);
if(pstPlaneNodeHead==NULL)
return;
characFlight[20];
PPlaneNodepstPlaneNodeCur=pstPlaneNodeHead-pstNext;
if(pstPlaneNodeCur==NULL)
printf("Noflighttomodifty!\n");
return;
else
printf("Inputtheflightnumberyouwanttomodify:\n");
scanf_s("%s",acFlight,20);
for(pstPlaneNodeCur;pstPlaneNodeCur!=NULL;pstPlaneNodeCur=pstPlaneNodeCur-pstNext)
if(strcmp(pstPlaneNodeCur-stDate.acFlight,acFlight)==0)
break;
if(pstPlaneNodeCur)
//子菜单
intisel=0;
system("cls");
Mod_menu();
printf("pleaseInput0-8:");
scanf_s("%d",isel);
getchar();
switch(isel)
case1:
printf("Inputnewflights!\n");
scanf("%s",pstPlaneNodeCur-stDate.acFlight);
break;
case2:
printf("InputnewOrigin!\n");
scanf("%s",pstPlaneNodeCur-stDate.acOrigin);
break;
case3:
printf("InputnewDestination!\n");
scanf("%s",pstPlaneNodeCur-stDate.acDest);
break;
case4:
printf("InputnewTakeofftime!\n");
scanf("%s",pstPlaneNodeCur-stDate.acTakeOffTime);
break;
case5:
printf("InputnewRevercetime!\n");
scanf("%s",pstPlaneNodeCur-stDate.acReverceTime);
break;
case6:
printf("InputnewPrices!\n");
scanf("%f",pstPlaneNodeCur-stDate.fPrice);
break;
case7:
printf("InputnewDisscount!\n");
scanf("%s",pstPlaneNodeCur-stDate.acDisscount);
break;
case8:
printf("Inputnewticketnumber!\n");
scanf("%d",pstPlaneNodeCur-stDate.iNum);
break;
case0:
printf("quit!\n");
break;
printf("EndModifyinginformation!\n");
else
printf("flightsnumbernotexist!\n");
显示机票信息
voidShow(PPlaneNodepstPlaneNodeHead)
assert(pstPlaneNodeHead!=NULL);
PPlaneNodepstPlaneNodeCur=pstPlaneNodeHead-pstNext;
PrintHead();
if(pstPlaneNodeHead-pstNext==NULL)
printf("noflightticket!\n");
else
while(pstPlaneNodeCur!=NULL)
PrintDate(pstPlaneNodeCur);
pstPlaneNodeCur=pstPlaneNodeCur-pstNext;
推荐机票信息
structManNode*FindMan(PManNodepstManNodeHead,characId[20])
PManNodepstManNodeCur=pstManNodeHead-pstNext;
for(pstManNodeCur;pstManNodeCur!=NULL;pstManNodeCur=pstManNodeCur-pstNext)
if(strcmp(pstManNodeCur-stDate.acID,acId)==0)//知道到id号相同的订票人的
returnpstManNodeCur;
returnNULL;
PPlaneNodeFindPlane(PPlaneNodepstPlaneNodeHead,char*acBookFlight)
PPlaneNodepstPlaneNodeCur=pstPlaneNodeHead-pstNext;
for(pstPlaneNodeCur;pstPlaneNodeCur!=NULL;pstPlaneNodeCur=pstPlaneNodeCur-pstNext)
if(strcmp(pstPlaneNodeCur-stDate.acFlight,acBookFlight)==0)//知道到id号相同的订票人的
returnpstPlaneNodeCur;
returnNULL;
voidRecommend(PPlaneNodepstPlaneNodeHead)
//推荐给用用户合适的机票
//时间地点
PPlaneNodepstPlaneNodeCur;
characDest[20];
characTime[10];
intiNum=0;
pstPlaneNodeCur=pstPlaneNodeHead-pstNext;
printf("Inputyourdestination");
scanf_s("%s",acDest,20);
printf("Inputtheearlisttimeyoucantake:");
scanf_s("%s",acTime,10);
PrintHead();
for(pstPlaneNodeCur;pstPlaneNodeCur!=NULL;pstPlaneNodeCur=pstPlaneNodeCur-pstNext)
if(strcmp(pstPlaneNodeCur-stDate.acDest,acDest)==0)
if(strcmp(acTime,pstPlaneNodeCur-stDate.acTakeOffTime)0)
PrintDate(pstPlaneNodeCur);
iNum++;
订票
voidBook(PPlaneNodepstPlaneNodeHead,PManNodepstManNodeHead)
//接收订票人头指针
PPlaneNodepstPlaneNodeCur,astPlaneNode[10];
PManNodepstManNodeCur,astManNodeTemp=NULL;
characDest[20];
characId[20];
characName[20];
characSex[10];
characDecision[2];
characFlight[20];
intiNum=0;
intiRecord=0;
intk=0;
chariFlag=0;
pstManNodeCur=pstManNodeHead;
for(pstManNodeCur;pstManNodeCur-pstNext!=NULL;pstManNodeCur=pstManNodeCur-pstNext);
//将订票人结构体指向尾巴
//输入目的地
printf("pleaseInputDestCity:\n");
scanf_s("%s",acDest,20);
getchar();
//查找目的地存入结构体数组中
pstPlaneNodeCur=pstPlaneNodeHead-pstNext;
for(pstPlaneNodeCur;pstPlaneNodeCur!=NULL;pstPlaneNodeCur=pstPlaneNodeCur-pstNext)
if(strcmp(pstPlaneNodeCur-stDate.acDest,acDest)==0)
astPlaneNode[iRecord]=pstPlaneNodeCur;
iRecord++;
printf("\nthereare%dflightyoucanchoose!\n",iRecord);
PrintHead();
for(k=0;kiRecord;k++)
PrintDate(astPlaneNode[k]);
if(iRecord==0)
printf("sorry,Noflightsyoucanbook!\n");
else
printf("doyouwanttobookit(y(Y)/n(N))");
scanf_s("%s",acDecision,2);
getchar();
if(strcmp(acDecision,"y")==0||strcmp(acDecision,"Y")==0)
printf("Inputyourinformation!\n");
astManNodeTemp=(PManNode)malloc(sizeof(ManNode));
//assert
printf("InputyourName:\n");
scanf_s("%s",acName,20);
strcpy(astManNodeTemp-stDate.acName,acName);
printf("InputyourId:\n");
scanf_s("%s",acId,20);
strcpy(astManNodeTemp-stDate.acID,acId);
printf("Inputyoursex(M/F):\n");
scanf_s("%s",acSex,10);
strcpy(astManNodeTemp-stDate.acSex,acSex);
printf("InputyourFlights:\n");
scanf_s("%s",acFlight,20);
strcpy(astManNodeTemp-stDate.acBookFilght,acFlight);
for(k=0;kiRecord;k++)
if(strcmp(astPlaneNode[k]-stDate.acFlight,acFlight)==0)
if(astPlaneNode[k]-stDate.iNum1)
printf("Notickets!");
return;
printf("return%dtickets!\n",astPlaneNode[k]-stDate.iNum);
iFlag=1;
break;
if(iFlag==0)
printf("error");
return;
printf("Inputthebooknumber:\n");//订购几张票
scanf_s("%d",iNum);
astPlaneNode[k]-stDate.iNum=astPlaneNode[k]-stDate.iNum-iNum;//还剩下的票数
astManNodeTemp-stDate.iBookNum=iNum;//订购票数
pstManNodeCur-pstNext=astManNodeTemp;//链接链表
astManNodeTemp-pstNext=NULL;
pstManNodeCur=astManNodeTemp;//移动当前链表指针位置
printf("FinishBook!\n");
}
退票
//退票
voidRefund(PPlaneNodepstPlaneNodeHead,PManNodepstManNodeHead)
PManNodepstManNodeCur,pstManNodeFind=NULL;
PPlaneNodepstPlaneNodeFind=NULL;
characId[20];
characDecision[2];
intiNum=0;//剩余票数
intiBookNum;//
//找到订票人的结构体
printf("InputyourId!\n");
scanf_s("%s",acId,20);
pstManNodeFind=FindMan(pstManNodeHead,acId);
if(pstManNodeFind==NULL)
printf("can;tfind!\n");
else//退票
printf("thisisyourtickets:\n");
printf("idnumber:%s\n",pstManNodeFind-stDate.acID);
printf("nmae:%s\n",pstManNodeFind-stDate.acName);
printf("sex:%s\n",pstManNodeFind-stDate.acSex);
printf("bookflight:%s\n",pstManNodeFind-stDate.acBookFilght);
printf("booknumber:%d\n",pstManNodeFind-stDate.iBookNum);
printf("doyouwanttocancelit(y/n)");
scanf_s("%s",acDecision,2);
getchar();
if(strcmp(acDecision,"y")==0)
//找到前驱
for(pstManNodeCur=pstManNodeHead;pstManNodeCur-pstNext!=pstManNodeFind;pstManNodeCur=pstManNodeCur-pstNext);
//找到该名订购人的航班记录
pstPlaneNodeFind=FindPlane(pstPlaneNodeHead,pstManNodeFind-stDate.acBookFilght);
//退票
if(pstPlaneNodeFind!=NULL)
iNum=pstPlaneNodeFind-stDate.iNum;//机票剩余票数
iBookNum=pstManNodeFind-stDate.iBookNum;//订购人订购票数
pstPlaneNodeFind-stDate.iNum=iNum+iBookNum;
//删除订票人节点
pstManNodeCur-pstNext=pstManNodeFind-pstNext;
printf("successful!\n");//成功退订
iSave=1;
free(pstManNodeFind);
}
保存信息
//保存机票信息
voidSavePlane(structPlaneNode*pstPlaneNodeHead)
FILE*pfPlane;//机票的文件指针
structPlaneNode*pstPlaneNodeCur;
intcount=0;//保存信息个数
intiFlag=1;
interror=0;
//pfPlane=fopen("plane.txt","wb");
error=fopen_s(pfPlane,"plane.txt","wb");
if(error!=0)
printf("thefilecan'tbeopened!\n");
return;
//写入信息
pstPlaneNodeCur=pstPlaneNodeHead-pstNext;
while(pstPlaneNodeCur!=NULL)
if(fwrite(pstPlaneNodeCur,sizeof(structPlaneNode),1,pfPlane)==1)
pstPlaneNodeCur=pstPlaneNodeCur-pstNext;
count++;
else
iFlag=0;
break;
//提示保存信息数目ISave置为0
if(iFlag)
printf("youhavesave%dflights\n",count);
iSave=0;
//关闭文件
fclose(pfPlane);
//保存订票人信息
voidSaveMan(structManNode*pstManNodeHead)
assert(pstManNodeHead!=NULL);
if(pstManNodeHead==NULL)
return;
FILE*pfMan;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 店面合伙出租协议书
- 律师线上合作协议书
- 技术人才培养协议书
- 政府审计保密协议书
- 平台项目转让协议书
- 广告资源采购协议书
- 房屋改造产权协议书
- 招标项目投资协议书
- 广州车牌使用协议书
- 房屋公用产权协议书
- 小小科学家《生物》模拟试卷A(附答案)
- 《康复医学》第一章第一节
- 论文联想与想象在语文教学中的应用及培养
- 2020年10月自考00152组织行为学试题及答案
- 食品营养与安全学智慧树知到答案章节测试2023年信阳农林学院
- 《森林培育学》考博复习资料
- DCF-现金流贴现模型-Excel模版(dcf-估值模型)
- 甘肃敦煌莫高窟简介
- GB/T 1839-2008钢产品镀锌层质量试验方法
- 制冷空调管件的焊接与质量控制
- 科技公司外部涉密信息导入涉密计算机审批表
评论
0/150
提交评论