




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
第C語言實現(xiàn)飛機訂票系統(tǒng)的完整代碼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);
//將訂票人結(jié)構(gòu)體指向尾巴
//輸入目的地
printf("pleaseInputDestCity:\n");
scanf_s("%s",acDest,20);
getchar();
//查找目的地存入結(jié)構(gòu)體數(shù)組中
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;//還剩下的票數(shù)
astManNodeTemp-stDate.iBookNum=iNum;//訂購票數(shù)
pstManNodeCur-pstNext=astManNodeTemp;//鏈接鏈表
astManNodeTemp-pstNext=NULL;
pstManNodeCur=astManNodeTemp;//移動當(dāng)前鏈表指針位置
printf("FinishBook!\n");
}
退票
//退票
voidRefund(PPlaneNodepstPlaneNodeHead,PManNodepstManNodeHead)
PManNodepstManNodeCur,pstManNodeFind=NULL;
PPlaneNodepstPlaneNodeFind=NULL;
characId[20];
characDecision[2];
intiNum=0;//剩余票數(shù)
intiBookNum;//
//找到訂票人的結(jié)構(gòu)體
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)
//找到前驅(qū)
for(pstManNodeCur=pstManNodeHead;pstManNodeCur-pstNext!=pstManNodeFind;pstManNodeCur=pstManNodeCur-pstNext);
//找到該名訂購人的航班記錄
pstPlaneNodeFind=FindPlane(pstPlaneNodeHead,pstManNodeFind-stDate.acBookFilght);
//退票
if(pstPlaneNodeFind!=NULL)
iNum=pstPlaneNodeFind-stDate.iNum;//機票剩余票數(shù)
iBookNum=pstManNodeFind-stDate.iBookNum;//訂購人訂購票數(shù)
pstPlaneNodeFind-stDate.iNum=iNum+iBookNum;
//刪除訂票人節(jié)點
pstManNodeCur-pstNext=pstManNodeFind-pstNext;
printf("successful!\n");//成功退訂
iSave=1;
free(pstManNodeFind);
}
保存信息
//保存機票信息
voidSavePlane(structPlaneNode*pstPlaneNodeHead)
FILE*pfPlane;//機票的文件指針
structPlaneNode*pstPlaneNodeCur;
intcount=0;//保存信息個數(shù)
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;
//提示保存信息數(shù)目ISave置為0
if(iFlag)
printf("youhavesave%dflights\n",count);
iSave=0;
//關(guān)閉文件
fclose(pfPlane);
//保存訂票人信息
voidSaveMan(structManNode*pstManNodeHead)
assert(pstManNodeHead!=NULL);
if(pstManNodeHead==NULL)
return;
FILE*pfMan;
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 醫(yī)療數(shù)據(jù)新紀(jì)元醫(yī)療信息共享平臺的建設(shè)與隱私保護
- 醫(yī)療行業(yè)運維知識庫的大數(shù)據(jù)應(yīng)用前景
- 親子拓展心得體會模版
- 醫(yī)療大數(shù)據(jù)在診斷中的創(chuàng)新應(yīng)用
- 辦公室健康的守護者-精準(zhǔn)醫(yī)療嵌入式辦公技術(shù)
- 醫(yī)療團隊在數(shù)字化時代的轉(zhuǎn)型發(fā)展
- 2025年幼兒園后勤工作總結(jié)模版
- 代加工月餅合同樣本
- 醫(yī)療設(shè)備追溯的區(qū)塊鏈技術(shù)應(yīng)用案例
- 傳媒公司拍攝合同標(biāo)準(zhǔn)文本
- 第五單元 生物與環(huán)境 大單元教學(xué)設(shè)計-2023-2024學(xué)年科學(xué)四年級下冊蘇教版
- 衛(wèi)生監(jiān)督信息員培訓(xùn)課件
- 杜邦分析法公式
- 五年級下冊勞動《編花籃》課件
- 2024年大唐集團招聘筆試試題及答案-
- 水泥路面損壞調(diào)查表(公式)
- 感染性休克指南解讀
- 《飲料對人體的危害》課件
- 2024及往年真題六西格瑪綠帶復(fù)習(xí)題及答案
- 失業(yè)保險制度對促進就業(yè)的實際影響的研究
- 2023年貴州黔東南州州直機關(guān)遴選公務(wù)員筆試真題
評論
0/150
提交評論