版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、課程:數(shù)據(jù)結(jié)構(gòu)專業(yè)班級:xx軟件工程xx班姓名:xx學(xué)號:xxx姓名:xxx學(xué)號:xxx設(shè)計(jì)時間:xxx指導(dǎo)老師:xxx曲為"CT#課程設(shè)計(jì)題:飛機(jī)訂票系統(tǒng)一、設(shè)計(jì)目的1 .掌握結(jié)構(gòu)體數(shù)組的表示和存儲。2.掌握鏈表的存儲和操作。3 .掌握文件的操作。二、設(shè)計(jì)內(nèi)容和要求1.任務(wù):通過此系統(tǒng)可以實(shí)現(xiàn)如下功能:錄入:可以錄入航班情況(數(shù)據(jù)可以存儲在一個數(shù)據(jù)文件中,數(shù) 據(jù)結(jié)構(gòu)、具體數(shù)據(jù)自定)查詢:可以查詢某個航線的情況(如,輸入航班號,查詢起降時 間,起飛抵達(dá)城市,航班票價,票價折扣,確定航班是否 滿倉);可以輸入起飛抵達(dá)城市,查詢飛機(jī)航班情況;訂票:訂票情況可以存在一個數(shù)據(jù)文件中,結(jié)構(gòu)自己
2、設(shè)定??梢?訂票,如果該航班已經(jīng)無票,可以提供相關(guān)可選擇航班;退票:可退票,退票后修改相關(guān)數(shù)據(jù)文件;客戶資料有姓名,證件號,訂票數(shù)量及航班情況,訂單要有編號。修改航班信息:當(dāng)航班信息改變可以修改航班數(shù)據(jù)文件。要求:根據(jù)以上功能說明,設(shè)計(jì)航班信息,訂票信息的存儲結(jié)端 St ”呎 構(gòu),設(shè)計(jì)程序完成功能 設(shè)計(jì)思想:管理操作系統(tǒng),主要考慮的是信息的錄入,這里利用文件的讀寫完成該 功能;輸出,查詢以及刪除,利用結(jié)構(gòu)數(shù)組存儲航班與客戶信息,依次 對訂票,退票,查詢及相關(guān)操作編寫成子程序,然后再主程序中調(diào)用, 這樣程序看起來相當(dāng)簡練,而且易讀懂;算法設(shè)計(jì)分析:(次系統(tǒng)運(yùn)行環(huán)境為 VC6.0)1.txtbei
3、ji ngsha nghai 1 1 12 0 1 1 18 06 100 2sha nghaiwuha ng 2 2 12 0 2 2 14 02 110 1wuha ng chibi 3 3 13 0 3 3 14 01 50 2(此文件是程序執(zhí)行航班信息錄入時自動生成,在信息讀取時需要調(diào) 用)首先是航班于客戶信息的存儲,結(jié)構(gòu)數(shù)組的利用很好的解決該問題; 其次是文件的操作,在主函數(shù)中利用文件的讀與寫;下面介紹訂票退票端?!眳找约安樵儾僮鞯膶?shí)現(xiàn)。1訂票:首先輸入出發(fā)地與目的地,查找是否有相應(yīng)的航班信息,在航2班票數(shù)足夠的情況下,錄入客戶信息,提示操作成功;否則失敗。3退票:輸入退票客戶的姓名
4、與身份號碼,查找到該客戶信息后進(jìn)行退 票操作,完成后對應(yīng)航班票數(shù)加1;若沒有該客戶信息,提示查無此人。查詢:輸入客戶姓名與身份號碼,若查到有該客戶信息,顯示該客戶的 航班情況;否則提示差無此人。/飛機(jī)定票管理系統(tǒng)#in clude<stdio.h>#i ncludevwi ndows.h>#defi ne N 10struct flightchar start10; 出發(fā)地int s_month;/出發(fā)時間月份,天,小時,分鐘int s_day;int s_hour;int s_mi nute;int d_month;/到達(dá)時間月份,天,小時,分鐘int d_day;int
5、d_hour;int d_minu te;int coast_t;/ 歷時多久int coast_m; 票價int num;/剩余票數(shù)/int bia nhao;/ 機(jī)票編號airN;結(jié)構(gòu)體數(shù)組存儲航班信息/客戶信息struct conint number;/定票者的證件號碼char start10;出發(fā)地char en d10; 目的地int s_month;/出發(fā)時間月份,天,小時,分鐘int s_day;int s_hour;int s_mi nute;int d_month;/到達(dá)時間月份,天,小時,分鐘int d_day;int d_hour;int d_minu te;int co
6、ast_t;/ 歷時多久int coast_m;/ 票價/ int bianhao;/ 機(jī)票編號people100;/定票,輸出發(fā)地與目的地,時間,反饋剩余票,票價book(i nt t)int i,mo nth,day,p,q,k=O;/k為判斷輸入的信息是否有誤printf("定票:n");/輸入查詢的航班信息,以便搜索while(k=O)printf("請輸入出發(fā)地,目的地,出發(fā)日期:n");/*gets(start);gets(e nd);/*這里輸入時應(yīng)注意用回車鍵否則默認(rèn)字符串存入 start*scan f("%d,%d"
7、,&mo nth, &day);/*/sca nf("%s,%s,%d,%d",start,e nd,&mo nth, &day);/ getchar();pri ntf("%s,%s,%d,%d",start,e nd,mo nth,day);/掃描信息,搜索與所查詢的航班匹配信息for(i=0;i<N;i+)p=strcmp(start,airi.start);q=strcmp(e nd,airi.e nd);if(p=0&&q=0&&mon th=airi.s_ month&am
8、p;&day=airi.s_day)k=1;/信息輸入無誤,即找到匹配信息printf("由%s到%s時間為%d月%d號的航班票價為 d,余票為 %dn",airi.start,airi.e nd,airi.s_mo nth,airi.s_day,airi.coast_m,airi. nu m);/更新信息,將客戶信息存儲if(airi.num=O)printf("票已售完,如有不便請諒解!nnnn");elseairi. num=airi. nu m-1;printf("請輸入您的證件號碼與姓名:n");scan f(&qu
9、ot;%d,%s",&peoplet. nu mber,peoplet. name);getchar();strcpy(peoplet.start,airi.start);strcpy(peoplet.e nd,airi.e nd);peoplet.s_ mon th=airi.s_mo nth;peoplet.s_day=airi.s_day;peoplet.s_hour=airi.s_hour;peoplet.s_mi nu te=airi.s_mi nu te;peoplet.d_ mon th=airi.d_ mon th;peoplet.d_day=airi.d_d
10、ay;peoplet.d_hour=airi.d_hour;peoplet.d_mi nu te=airi.d_mi nu te;peoplet.coast_t=airi.coast_t;peoplet.coast_m=airi.coast_m;/peoplet.bia nhao=airi.bia nhao;printf("恭喜您定票成功!nnnn");t+;/ system("pause");if(k=O)printf("信息輸入有誤n");printf("是否繼續(xù)定票?0為繼續(xù)1為退出n");scan f(&q
11、uot;%d",&k);getchar();return t;/退票,并將客戶信息欄中該客戶信息清楚,所乘航班票數(shù)加1re_ti(i nt t)int i,j,n u_mber,k=0;/k為判斷是否查找到客戶信息char n a_me10;printf("退票:n");printf("請輸入證件號碼與客戶姓名:n");scan f("%d,%s", &nu_ mber, na_me);getchar();for(i=0;i<100;i+)if(nu_ mber=peoplei. nu mber&
12、;&strcmp( na_me,peoplei. name)=0)k=1;找到該客戶信息/退票后,與該客戶對應(yīng)航班票數(shù)增1for(j=0;j<N;j+)if(strcmp(peoplei.start,airj.start)=0&&strcmp(peoplei.e nd,airj.e nd)=0&&peoplei.s_ mon th=airj.s_ mon th&&peoplei.s_day=airj.s_day)airj. num=airj. nu m+1;/將客戶信息依次向前移動for(j=i;j<100;j+)/ prin
13、 tf(" 成功刪除該客戶信息!n");peoplej. nu mber=peoplej+1. nu mber;strcpy(peoplej. name,peoplej+1. name); strcpy(peoplej.start,peoplej+1.start);strcpy(peoplej.e nd,peoplej+1.e nd);peoplej.s_ mon th=peoplej+1.s_ mon th; peoplej.s_day=peoplej+1.s_day;peoplej.s_hour=peoplej+1.s_hour;peoplej.s_mi nu te=p
14、eoplej+1.s_mi nu te; peoplej.d_ mon th=peoplej+1.d_ mon th; peoplej.d_day=peoplej+1.d_day;peoplej.d_hour=peoplej+1.d_hour;peoplej.d_ minu te=peoplej+1.d_ minu te; peoplej.coast_t=peoplej+1.coast_t;peoplej.coast_m=peoplej+1.coast_m;t=t-1;/刪除該客戶信息后,客戶記錄減去1if(k=0)printf("查無此人!n");prin tf(&quo
15、t;nnnn");return t;/查詢信息,出入所要查詢的顧客的航班信息,并給出錯誤處理check()int i,n u_mber,k=O;/k為判斷是否查找到客戶信息char n a_me10;printf("查詢:n");printf("請輸入證件號碼與客戶姓名:n");/ getch();fflush(stdi n);scan f("%d,%s", &nu_ mber, na_me);for(i=0;i<100;i+)if(nu_ mber=peoplei. nu mber&&strc
16、mp( na_me,peoplei. name)=0)k=1;printf("以下是該客戶信息:n");printf("證件號:%d;姓名:%s;出發(fā)地:%s;目的地:%s;出發(fā)時間:%d月%d日%d時%d分n ”,peoplei. nu mber,peoplei. name,peoplei.start,peoplei.e nd,peoplei.s_ month,peoplei.s_day,peoplei.s_hour,peoplei.s_ minu te);prin tf("nnnn"); if(k=O)printf("查無此人!n
17、nnn");mai n()/使用文件初始化信息int s,p,q=O,i;/p,q為循環(huán)判斷變量int t=0;/* FILE *fp;char n ame="1.txt"if(!(fp=fope n("1.txt","w")pri ntf("error!n");for(i=0;i<3;i+)fprin tf(fp,"%15s%15s%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4dn",airi.start,airi.e nd,airi.s_ mon th,ai
18、ri.s_day,airi.s_hour.airi.s_mi nu te,airi.d_ mon th,airi.d_day,airi.d_hour,airi.d_mi nu te,airi.coast_t,airi.coast_m,airi. nu m);fclose(fp);*/FILE *fp;char n ame="1.txt"if(!(fp=fope n("1.txt","r")pri ntf("error!n");for(i=0;i<3;i+) fscan f(fp,"%15s%15s%
19、4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4dn",& airi.start,&airi.e nd,& airi.s_ mon th, &airi.s_day,&airi.s_hour.& airi.s_mi nute, &airi.d_ mon th,&airi.d_day, &airi.d_hour, &airi.d_mi nute,& airi.coast_t, &airi.coast_m,&airi. nu m);fclose(fp);/ char n ame;/read conument while(q=0)printf(II *n);printf("請選擇服務(wù)種類:n1為定票;2為退票;3查找信息;0為退出n");printf(II *n);/system("pause");scan f("%d", &s);getchar();switch(s)ca
溫馨提示
- 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度企業(yè)知識產(chǎn)權(quán)質(zhì)押貸款合同-@-2
- 課題申報(bào)參考:能源轉(zhuǎn)型下居民親環(huán)境行為的變遷趨勢及提升路徑研究
- 課題申報(bào)參考:面向韌性發(fā)展的城市群醫(yī)療資源供需適配研究
- 2025年個人無息借款合同樣本:無息借款協(xié)議:扶持文化藝術(shù)項(xiàng)目2篇
- 二零二五版民政局批準(zhǔn)離婚協(xié)議書范本8篇
- 2025年度綠色能源項(xiàng)目內(nèi)部股東權(quán)益轉(zhuǎn)讓合同4篇
- 二零二五年度南京市房產(chǎn)局制定的房屋抵押權(quán)登記合同模板4篇
- 2025年度戀愛期間共同理財(cái)規(guī)劃與投資合同4篇
- 2025年度個人信用借款擔(dān)保合同范本3篇
- 2025版車輛抵押借款合同(含貸款利率調(diào)整)4篇
- 護(hù)理飲食指導(dǎo)整改措施及方案
- 項(xiàng)目工地春節(jié)放假安排及安全措施
- 印染廠安全培訓(xùn)課件
- 紅色主題研學(xué)課程設(shè)計(jì)
- 胸外科手術(shù)圍手術(shù)期處理
- 裝置自動控制的先進(jìn)性說明
- 《企業(yè)管理課件:團(tuán)隊(duì)管理知識點(diǎn)詳解PPT》
- 移動商務(wù)內(nèi)容運(yùn)營(吳洪貴)任務(wù)二 軟文的寫作
- 英語詞匯教學(xué)中落實(shí)英語學(xué)科核心素養(yǎng)
- 《插畫設(shè)計(jì)》課程標(biāo)準(zhǔn)
- 高中英語名詞性從句講解
評論
0/150
提交評論