




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、#include/預(yù)處理函數(shù)#include/標(biāo)準(zhǔn)庫函數(shù)#include/字符串函數(shù)#include/通過鍵盤來控制程序調(diào)試int o=0;typedef struct zuoweiint a;/車座int b;/車廂seat;typedef struct Tmess/定義一個結(jié)構(gòu)體存儲火車訂票的信息 char tnum8;/火車車次char time18;/發(fā)車時間char station18;/出發(fā)站char station28;/終點站char tujingstation8;/途經(jīng)站char time28;/到站時間char money5;/票價tmess;typedef struct
2、in/定義一個結(jié)構(gòu)體存儲火車座位信息tmess data;/調(diào)用火車的信息 int reseat;/剩余票 seat seatnum;struct in *next;/定義next指針in;typedef struct pmess/定義一個結(jié)構(gòu)體存儲乘客信息char name10;/姓名char tel15;/電話char id20;/身份證char booknum3;/訂票數(shù)目char checi8;/車次pmess;typedef struct people/乘客信息pmess m;/調(diào)用pmess結(jié)構(gòu)體struct people *next;/定義next指針people;struct
3、dingdanint danhao;char tnum8;/火車車次char time18;/發(fā)車時間char station18;/出發(fā)站char station28;/終點站char tujingstation8;/途經(jīng)站char time28;/到站時間char money5;char name10;/姓名char tel15;/電話char id20;/身份證char booknum3;/訂票數(shù)目char seat10;char seatnum10;dingdan100;void end();void admin();void book(in *h,people *k);void ca
4、ncel();void chaxuntrain(in *h);in *fangshi(in *h,char findmess,char numorcity);void print();void passenger();void putoutticket(in *p);void putticket(in *h);void widows();int main()for(int i=0;inext=NULL;k=(people*)malloc(sizeof(people);k-next=NULL;p=h;v=k;while(1)system(cls);widows();scanf(%d,&wp);f
5、flush(stdin);system(cls);switch(wp)case 1:putticket(h);break;case 2:chaxuntrain(p);break;case 3: book(p,v);break;case 4: print();break;case 5:cancel();break;default:break;printf(n請按任何鍵結(jié)束n);getch(); return 0;void end()/結(jié)束頁面函數(shù)puts(*);printf( 謝謝使用n); void widows()/初始頁面函數(shù);printf(*n);printf( * # * n);pri
6、ntf( * # * n);printf( * # * n);printf( * # *n);printf( * # * n);printf( * # *n);printf( * # *n);printf( * # *n);printf( * # *n);printf( * # *n);printf( * # 1,輸入車次信息 * n);printf( * # 2,查詢車次 * n);printf( * # 3,訂票 * n);printf( * # 4,訂單查詢 * n);printf( * # 5,退票 *n);printf( * # 6,退出系統(tǒng) * n);printf( * # *n)
7、;printf(*n);printf( 請輸入選擇:);void putticket(in *h)/輸入車次信息 in *p,*l,*s;/定義了三個指針變量char num8;/定義了數(shù)組p=h;/p指向尾節(jié)點l=h-next;/l指針遍歷火車信息while(p-next)p=p-next;while(1)printf(請輸入要添加的火車車次(按0退出)n);scanf(%s,&num); fflush(stdin);if(strcmp(num,0)=0)break;while(l)if(strcmp(l-data.tnum,num)=0)/比較的輸入車次與之前存在車次printf(該車次已
8、經(jīng)存在n);return ;l=l-next;/l+ s=(in *)malloc(sizeof(in);strcpy(s-data.tnum,num);/復(fù)制函數(shù),加入新的車次printf(請輸入出發(fā)時間:n);scanf(%s,&s-data.time1); fflush(stdin);printf(請輸入出發(fā)城市:n);scanf(%s,&s-data.station1); fflush(stdin);printf(請輸入到達(dá)時間:n);scanf(%s,&s-data.time2); fflush(stdin);printf(請輸入到達(dá)城市:n);scanf(%s,&s-data.st
9、ation2); fflush(stdin);printf(請輸入途徑大站:n); scanf(%s,&s-data.tujingstation); fflush(stdin);printf(請輸入票價:n);scanf(%s,&s-data.money); fflush(stdin); s-seatnum.a=1; s-seatnum.b=1;s-reseat=-1;s-next=NULL;p-next=s;p=s;void putoutticket(in *p)/打印火車信息 printf(n下面是火車信息n);printf(車次:%sn,p-data.tnum);printf(出發(fā)時間:
10、%sn,p-data.time1);printf(始發(fā)站:%sn,p-data.station1);printf(到達(dá)時間:%sn,p-data.time2);printf(終點站:%sn,p-data.station2); printf(途經(jīng)站:%sn,p-data.tujingstation);printf(票價:%sn,p-data.money);printf(剩余票數(shù):%d,1000-p-reseat);in *fangshi(in *h,char findmess,char numorcity)/查詢方式 in *p;if(strcmp(numorcity,num)=0)/按車次查詢
11、p=h-next;while(p)if(strcmp(p-data.tnum,findmess)=0)/查到與車次信息相符的return p;/返回所查到的信息p=p-next;if(strcmp(numorcity,city)=0)/按城市查詢p=h-next;while(p)if(strcmp(p-data.station2,findmess)=0)/查到與城市信息相符的return p;/返回所查到的信息p=p-next;return 0;void chaxuntrain(in *h)/信息查詢in *p;char str110;int sel;if(h-next=NULL)printf
12、(沒有任何火車信息n);return ;printf(n請選擇查詢方式n1.車次查詢 2.城市查詢n);scanf(%d,&sel); fflush(stdin);if(sel=1)printf(請輸入車次n);scanf(%s,str1); fflush(stdin);p=fangshi(h,str1,num);if(p)putoutticket(p);else printf(n沒有找到n);else if(sel=2)printf(請輸入到達(dá)城市n);scanf(%s,str1); fflush(stdin);p=fangshi(h,str1,city);if(p)putoutticket
13、(p);else printf(n沒有找到n);void book(in *h,people *k)/訂票輸入乘客信息,訂票數(shù) in *p,*l;/定義兩個in結(jié)構(gòu)體下的指針變量people *v,*s;/定義兩個people結(jié)構(gòu)體下的指針變量int i=0,t=0,wp,i2=1;char str110,str210;/定義兩個數(shù)組分別用來存儲到達(dá)城市和車次信息l=h;v=k;extern int o;while(v-next)v=v-next;/v指針遍歷火車信息printf(請輸入想要達(dá)到的城市n);scanf(%s,&str1); fflush(stdin);p=fangshi(l,s
14、tr1,city);/按城市搜索的查詢方式printf(請輸入想要的車次n);scanf(%s,&str2); fflush(stdin);p=fangshi(l,str2,num);/按車次搜索的查詢方式if(!p)printf(n沒有找到到達(dá)該城市的車次n);return ;else putoutticket(p);/調(diào)用outoutticket函數(shù)printf(是否要訂這個車次?n); scanf(%d,&wp); fflush(stdin); if(wp) s=(people*)malloc(sizeof(people);printf(請輸入姓名:); scanf(%s,&s-m.na
15、me); fflush(stdin); printf(請輸入電話:); scanf(%s,&s-m.tel); fflush(stdin); printf(請輸入身份證號:); scanf(%s,&s-m.id); fflush(stdin); printf(請輸入要訂的票數(shù):); scanf(%s,&s-m.booknum); fflush(stdin);s-next=NULL; v-next=s; v=s; strcpy(s-m.checi,p-data.tnum); p-reseat=p-reseat+(int)(atof(s-m.booknum);if(p-seatnum.aseatn
16、um.a,p-seatnum.b);p-seatnum.a=p-seatnum.a+1;elseif(p-seatnum.bseatnum.a,p-seatnum.b);p-seatnum.b=p-seatnum.b+1;p-seatnum.a=1; printf(nOK!訂票成功n); strcpy(dingdano.tnum,p-data.tnum); strcpy(dingdano.time1,p-data.time1); strcpy(dingdano.station1,p-data.station1);strcpy(dingdano.station2,p-data.station2)
17、; strcpy(dingdano.tujingstation,p-data.tujingstation);strcpy(dingdano.time2,p-data.time2);strcpy(dingdano.money,p-data.money); strcpy(,); strcpy(dingdano.tel,s-m.tel); strcpy(dingdano.id,s-m.id); strcpy(dingdano.booknum,s-m.booknum);printf(訂單號為:%dn,dingdano.danhao);printf(座位號為:%
18、s(座位號/車廂號)n,dingdano.seatnum); o+; getch(); void cancel()int count=0;extern int o;char q5=失效;int p;int s=0;char passname20;printf(請輸入乘客姓名:);scanf(%s/n,passname);for(int i=0;io;i+)if(strcmp(passname,)=0)printf(*n);printf(* 這是訂單號為%d的訂單信息 *n,dingdani.danhao); printf(*n);printf(* 火車車次:%s *n
19、,dingdani.tnum); printf(* 發(fā)車時間:%s *n,dingdani.time1); printf(* 出發(fā)站:%s *n,dingdani.station1); printf(* 終點站:%s *n,dingdani.station2); printf(* 途徑站:%s *n,dingdani.tujingstation);printf(* 到站時間:%s *n,dingdani.time2); printf(* 票價:%s *n,dingdani.money);printf(* 姓名:%s *n,);printf(* 電話:%s *n,din
20、gdani.tel);printf(* 身份證:%s *n,dingdani.id);printf(* 訂票數(shù)目:%s *n,dingdani.booknum);printf(* 座位號:%s *n,dingdani.seatnum); printf(*n);printf(-n);count+;if(count=0)printf(未找到該乘客的訂票信息n);goto low;printf(請輸入要刪除的訂單編號:);scanf(%dn,&p);for(s=0;so;s+) if(p=dingdans.danhao) strcpy(dingdans.tnum,q); strcpy(dingdan
21、s.time1,q); strcpy(dingdans.station1,q);strcpy(dingdans.station2,q); strcpy(dingdans.tujingstation,q);strcpy(dingdans.time2,q);strcpy(dingdans.money,q); strcpy(,q); strcpy(dingdans.tel,q); strcpy(dingdans.id,q); strcpy(dingdans.booknum,q); printf(*n);printf(* 這是訂單號為%d的訂單信息 *n,dingdans.d
22、anhao); printf(*n);printf(* 火車車次:%s *n,dingdans.tnum); printf(* 發(fā)車時間:%s *n,dingdans.time1); printf(* 出發(fā)站:%s *n,dingdans.station1); printf(* 終點站:%s *n,dingdans.station2); printf(* 途徑站:%s *n,dingdans.tujingstation);printf(* 到站時間:%s *n,dingdans.time2); printf(* 票價:%s *n,dingdans.money);printf(* 姓名:%s *
23、n,);printf(* 電話:%s *n,dingdans.tel);printf(* 身份證:%s *n,dingdans.id);printf(* 訂票數(shù)目:%s *n,dingdans.booknum);printf(* 座位號:%s *n,dingdani.seatnum); printf(*n);printf(-n); low:;void admin()int password=1;extern int o;int n;printf(請輸入管理員密碼:);scanf(%dn,&n); fflush(stdin);if(password=n)for(int
24、i=0;io;i+)printf(*n);printf(* 這是訂單號為%d的訂單信息 *n,dingdani.danhao); printf(*n);printf(* 火車車次:%s *n,dingdani.tnum); printf(* 發(fā)車時間:%s *n,dingdani.time1); printf(* 出發(fā)站:%s *n,dingdani.station1); printf(* 終點站:%s *n,dingdani.station2); printf(* 途徑站:%s *n,dingdani.tujingstation);printf(* 到站時間:%s *n,dingdani.time2); printf(* 票價:%s *n,dingdani.money);printf(* 姓名:%s *n,);printf(* 電話:%s *n,dingdani.tel);printf(* 身份證:%s *n,dingdani.id);printf(* 訂票數(shù)目:%s *n,dingdani.booknum);printf(* 座位號:%s *n,dingdani.seatnum); printf(*n);printf(-n);void passenger()char passname20;printf(請輸入乘
溫馨提示
- 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è)品牌策劃設(shè)計合同范例
- 代理樓盤合同范例
- 公路大修合同范例
- 創(chuàng)辦企業(yè)合同范例
- 借用材料合同范例
- 買方角度貨物出口合同范例
- 公司工商合同范例
- 共同承包工地合同范例
- 債務(wù)減免合同范例
- 醫(yī)療器械醫(yī)療器械研發(fā)合同
- 2025年岳陽職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫及參考答案
- (二模)2024-2025學(xué)年佛山市順德區(qū)高三教學(xué)質(zhì)量檢測 (二)歷史試卷(含答案)
- 2024初級會計職稱考試題庫(附參考答案)
- 國家安全教育大學(xué)生讀本高教社2024年8月版教材講義-第一章完全準(zhǔn)確領(lǐng)會總體國家安全觀
- 2025年四川省對口招生(旅游類)《前廳服務(wù)與管理》考試復(fù)習(xí)題庫(含答案)
- 2024年01月河北2024年唐山銀行社會招考筆試歷年參考題庫附帶答案詳解
- 【高++中語文++】《記念劉和珍君》課件+統(tǒng)編版高中語文選擇性必修中冊
- 2025年湖南信息職業(yè)技術(shù)學(xué)院高職單招職業(yè)技能測試近5年常考版參考題庫含答案解析
- 2025年江西環(huán)境工程職業(yè)學(xué)院高職單招職業(yè)技能測試近5年??及鎱⒖碱}庫含答案解析
- 2024年世界職業(yè)院校技能大賽高職組“研學(xué)旅行組”賽項參考試題庫(含答案)
評論
0/150
提交評論