C語(yǔ)言知識(shí)學(xué)習(xí)飛機(jī)訂票系統(tǒng)_第1頁(yè)
C語(yǔ)言知識(shí)學(xué)習(xí)飛機(jī)訂票系統(tǒng)_第2頁(yè)
C語(yǔ)言知識(shí)學(xué)習(xí)飛機(jī)訂票系統(tǒng)_第3頁(yè)
C語(yǔ)言知識(shí)學(xué)習(xí)飛機(jī)訂票系統(tǒng)_第4頁(yè)
C語(yǔ)言知識(shí)學(xué)習(xí)飛機(jī)訂票系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩22頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、課程設(shè)計(jì)課程:數(shù)據(jù)結(jié)構(gòu)專業(yè)班級(jí):XX軟件工程XX班姓名:XX學(xué)號(hào):XXX姓名:XXX學(xué)號(hào):XXX設(shè)計(jì)時(shí)間XXX指導(dǎo)老師:XXX課程設(shè)計(jì)題:飛機(jī)訂票系統(tǒng)1 .掌握結(jié)構(gòu)體數(shù)組的表示和存儲(chǔ)。2.掌握鏈表的存儲(chǔ)和操作。3 .掌握文件的操作。二、設(shè)計(jì)內(nèi)容和要求1.任務(wù):通過(guò)此系統(tǒng)可以實(shí)現(xiàn)如下功能:錄入:可以錄入航班情況(數(shù)據(jù)可以存儲(chǔ)在一個(gè)數(shù)據(jù)文件中,數(shù)據(jù) 結(jié)構(gòu)、具體數(shù)據(jù)自定)查詢:訂票:可以查詢某個(gè)航線的情況(如,輸入航班號(hào),查詢起降時(shí)間,起飛抵達(dá)城市,航班票價(jià),票價(jià)折扣,確定航班是否滿倉(cāng));可以輸入起飛抵達(dá)城市,查詢飛機(jī)航班情況;訂票情況可以存在一個(gè)數(shù)據(jù)文件中,結(jié)構(gòu)自己設(shè)定??梢杂喥?,如果該航班已經(jīng)無(wú)

2、票,可以提供相關(guān)可選擇航班;可退票,退票后修改相關(guān)數(shù)據(jù)文件;客戶資料有姓名,證件號(hào),訂票數(shù)量及航班情況,訂單要有編號(hào)。修改航班信息:當(dāng)航班信息改變可以修改航班數(shù)據(jù)文件。要求:根據(jù)以上功能說(shuō)明,設(shè)計(jì)航班信息,訂票信息的存儲(chǔ)結(jié)構(gòu), 設(shè)計(jì)程序完成功能管理操作系統(tǒng),主要考慮的是信息的錄入,這里利用文件的讀寫(xiě)完成該 功能;輸出,查詢以及刪除,利用結(jié)構(gòu)數(shù)組存儲(chǔ)航班與客戶信息,依次 對(duì)訂票,退票,查詢及相關(guān)操作編寫(xiě)成子程序,然后再主程序中調(diào)用, 這樣程序看起來(lái)相當(dāng)簡(jiǎn)練,而且易讀懂;算法設(shè)計(jì)分析:(次系統(tǒng)運(yùn)行環(huán)境為 VC6.0)1.txtbejingsha nghai 11 12 01 18 06 100 2

3、sha nghaiwuhang2 2 122 2 140 2 110 1wuhangchibi 33 13 03 14 01 50 2(此文件是程序執(zhí)行航班信息錄入時(shí)自動(dòng)生成,在信息讀取時(shí)需要調(diào) 用) 首先是航班于客戶信息的存儲(chǔ),結(jié)構(gòu)數(shù)組的利用很好的解決該問(wèn)題;其次是文件的操作,在主函數(shù)中利用文件的讀與寫(xiě);下面介紹訂票退票 以及查詢操作的實(shí)現(xiàn)。1訂票:首先輸入出發(fā)地與目的地,查找是否有相應(yīng)的航班信息,在航 2班票數(shù)足夠的情況下,錄入客戶信息,提示操作成功;否則失敗。3退票:輸入退票客戶的姓名與身份號(hào)碼,查找到該客戶信息后進(jìn)行退票操作,完成后對(duì)應(yīng)航班票數(shù)加1 ;若沒(méi)有該客戶信息,提示查無(wú)此 人。

4、查詢:輸入客戶姓名與身份號(hào)碼,若查到有該客戶信息,顯示該客戶的 航班情況;否則提示差無(wú)此人。/飛機(jī)定票管理系統(tǒng)#in cludevstdio.h#i ncludevwi ndows.h#defi ne N 10 struct flightchar start10;/ 出發(fā)地char en d10;/目的地int s_mon th;/出發(fā)時(shí)間月份,天,小時(shí),分鐘int s_day;int s_hour;int s_mi nute;int d_mon th;/到達(dá)時(shí)間月份,天,小時(shí),分鐘int d_day;int d_hour;int d_minute;int coast_t;/歷時(shí)多久int c

5、oast_m;/ 票價(jià)int num;/ 剩余票數(shù)/int bia nhao;/機(jī)票編號(hào)airN;/結(jié)構(gòu)體數(shù)組存儲(chǔ)航班信息/客戶信息struct conint number;/定票者的證件號(hào)碼char n ame10;/ 定票者的名字char start10;/ 出發(fā)地char en d10;/目的地int s_mon th;/出發(fā)時(shí)間月份,天,小時(shí),分鐘int s_day;int s_hour;int s_mi nute;int d_mon th;/到達(dá)時(shí)間月份,天,小時(shí),分鐘int d_day;int d_hour;int d_minute;int coast_t;/歷時(shí)多久int coa

6、st_m;/ 票價(jià)/int bia nhao;/ 機(jī)票編號(hào)peop le100;/定票,輸出發(fā)地與目的地,時(shí)間,反饋剩余票,票價(jià) book(i nt t)int i,m on th,day, p,q,k=0;/k為判斷輸入的信息是否有誤char start10,e nd10;printf("定票:n");/輸入查詢的航班信息,以便搜索 while(k=0)printf("請(qǐng)輸入出發(fā)地,目的地,出發(fā)日期:n");/*gets(start);gets(e nd);/*這里輸入時(shí)應(yīng)注意用回車鍵,否則默認(rèn)字符串存入start*scan f("%d,%d

7、",&mo nth, &day);/*/sea nf("%s,%s,%d,%d",staite nd,&mo nth, &day);/getchar();p ri ntf("%s,%s,%d,%d",start,e nd,mo nth,day);/掃描信息,搜索與所查詢的航班匹配信息for(i=0;ivN;i+)P=strcm p( start,airi.start);q=strc mp(en d,airi.e nd);if(p=0&&q=0&&mon th=airi.s_ mon

8、th&&day=airi.s_day)k=1;/信息輸入無(wú)誤,即找到匹配信息 printf("由%s到%s時(shí)間為%d月%d號(hào)的航班票價(jià)為 %d,余票為 %dn",airi.start,airi.e nd,airi.s_mo nth,airi.s_day,airi.coast_m,airi. nu m);/更新信息,將客戶信息存儲(chǔ)if(airi.num=0)printf("票已售完,如有不便請(qǐng)諒解!nnnn");elseairi. num=airi. nu m-1;printf("請(qǐng)輸入您的證件號(hào)碼與姓名:n");sca

9、 nf("%d,%s",&peopl et. nu mber ,peopl et. name);getcharO;strc py(peopl et.start,airi.start);strc py(peopl et.e nd,airi.e nd);peopi et.s_ mon th=airi.s_ month;peopi et.s_day=airi.s_day;peop let.s_hour=airi.s_hour;peop let.s_mi nu te=airi.s_mi nute;peopi et.d_ mon th=airi.d_ month;peopi

10、et.d_day=airi.d_day;peopi et.d_hour=airi.d_hour;peop let.d_mi nu te=airi.d_mi nute;peopi et.coast_t=airi.coast_t;/peopi et.coast_m=airi.coast_m;peopi et.bia nhao=airi.bia nhao;printf(”恭喜您定票成功!nnnn");t+;/system(" pause");if(k=O)printf("信息輸入有誤n");printf("是否繼續(xù)定票?0為繼續(xù)1為退出n&

11、quot;);scan f("%d",&k);getcharO;return t;/退票,并將客戶信息欄中該客戶信息清楚,所乘航班票數(shù)加1 re_ti(i nt t)int i,j,n u_mber,k=0;/k為判斷是否查找到客戶信息char n a_me10;printf("退票:n");printf("請(qǐng)輸入證件號(hào)碼與客戶姓名:n");scan f("%d,%s", &nu_ mber, na_me);getchar();for(i=0;iv100;i+) if(nu _mber=peopi

12、ei. nu mber&&strcm p(n a_me ,peopl ei. name)=0)k=1;/找到該客戶信息/退票后,與該客戶對(duì)應(yīng)航班票數(shù)增1 for(j=0;j<N;j+)if(strc mp(peopl ei.start,airj.start)=0&&strc mp(peopl ei.e nd,airj.e nd)=0&&peopl ei.s_ mon th=airj.s_ month&&peopl ei.s_day=airj.s_day)airj. num=airj. nu m+1;/將客戶信息依次向前移動(dòng)f

13、or(j=i;jv100;j+)/ prin tf("成功刪除該客戶信息!n");peopi ej. nu mber=peopl ej+1. nu mber;strc py(peopl ej. name ,peopl ej+1. name);strc py(peopl ej.start ,peopl ej+1.start);strc py(peopl ej.e nd,peopl ej+1.e nd);peop lej.s_ mon th=peop lej+1.s_mo nth;peop lej.s_day=peop lej+1.s_day;peopi ej.s_hour=p

14、eopl ej+1.s_hour;peopi ej.s_ minu te=peopi ej+1.s_ minute;peopi ej.d_ mon th=peopi ej+1.d_ month;peopi ej.d_day=peopi ej+1.d_day;peopi ej.d_hour =peopl ej+1.d_hour;peopi ej.d_ minu te=peopi ej+1.d_ minute;peopi ej.coast_t=peopi ej+1.coast_t;peop lej.coast_m=peop le|+1.coast_m;t=t-1;/刪除該客戶信息后,客戶記錄減去1

15、if(k=0)printf("查無(wú)此人!n");prin tf("nnnn");return t;/查詢信息,出入所要查詢的顧客的航班信息,并給出錯(cuò)誤處理check()int i,n u_mber,k=0;/k為判斷是否查找到客戶信息char n a_me10;printf("查詢:n");printf("請(qǐng)輸入證件號(hào)碼與客戶姓名:n");/getch();/fflush(stdi n);scan f("%d,%s", &nu_ mber, na_me);for(i=0;i<100

16、;i+) if(nu _mber=peopi ei. nu mber&&strcm p(n a_me ,peopl ei. name)=0)k=1;printf("以下是該客戶信息:n");printf("證件號(hào):%d;姓名:%s;出發(fā)地:%s;目的地:%s;出發(fā)時(shí)間:%d月%d日%d時(shí)%d分n ”, peopi ei. nu mber, peopi ei. name ,peopl ei.start ,peopl ei.e nd,peopl ei.s_m on th, peopi ei.s_day ,peopl ei.s_hour, peopi e

17、i.s_ minu te);prin tf("nnnn");if(k=0)printf("查無(wú)此人!nnnn");mai n()/使用文件初始化信息int s,p ,q=O,i;/p,q為循環(huán)判斷變量int t=0;/*FILE *fp;char n ame="1.txt"if(!(fp=fo pen( "1.txt","w")p ri ntf("error!n");for(i=0;iv3;i+) fprin tf(fp,"%15s%15s%4d%4d%4d%4d%

18、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 nu te,airi.d_mo nth,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=fo pen ("1.txt","r")pri ntf(

19、"error!n");for(i=0;iv3;i+) fscan f(fp,"%15s%15s%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_mo nth,&airi.d_day, &airi.d_hour, &airi.d_min ute,&airi.coast_

20、t, &airi.coast_m,&airi. nu m);fclose(fp);/char n ame;/read conument while(q=0)prin tf("*n")printf("請(qǐng)選擇服務(wù)種類:n1為定票;2為退票;3查找信息;0為退出n");prin tf("*n")/system(" pause");scan f("%d", &s);getcharO;switch(s)case 1:t=book(t);/訂票操作break;case 2:t=re_ti(t);/退票操作break;case 3:check();/查找客戶信息是否存在break;case 0:printf("航空集團(tuán)祝福您旅途愉快門(mén);printf("您確定離開(kāi)界面?1/0n");scan f("%d",&p);if(P=1)q=1;else q=0;隣翳S霹汩查找信息期退岀1定票:請(qǐng)覲V岀發(fā)地,目的地岀發(fā)0期=beijingshanghai1,1I、beijingshansfhai,!,!由bei jing到srhemsrKa;!時(shí)間為1月1號(hào)的航班票價(jià)為】

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論