




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上#include<stdio.h>#include<stdlib.h>#define stacksize 2 /車站/容量/typedef struct Snode int number; float int_time2; float bian_time2;record;typedef struct record *base; record *top; int size;Stack;/typedef struct Qnode int number; float int_time2; struct Qnode *next;Qnode,*Queue
2、;typedef struct Queue front; Queue rear;Linkqueue;void xunhuan(Stack L,Linkqueue Q);void jixu(Stack L,Linkqueue Q);/void InitStack(Stack &L) /堆棧操作 L.base=(record*)malloc(sizeof(Snode)*stacksize); if(!L.base) exit(0); L.top=L.base; L.size=stacksize;/void input(Stack &L,record h) *L.top+=h; /S
3、node output(Stack &L,record &e) e=*-L.top; return e; int Stackman(Stack L) if(L.top-L.base=L.size) return 0; else return 1;int StackEmpty(Stack L) if(L.base=L.top) return 0; else return 1;/void Initque(Linkqueue &Q) /隊(duì)列操作 Q.front=Q.rear=(Queue)malloc(sizeof(Qnode); if(!Q.front) exit(0);
4、Q.front->next=NULL;/void enqueue(Linkqueue &Q,int number,float time) Queue q; printf("停車場(chǎng)已滿,請(qǐng)將車輛停入便道!n"); q=(Queue)malloc(sizeof(Qnode); q->int_time0=time0; q->int_time1=time1; q->number=number; q->next=NULL; Q.rear->next=q; Q.rear=q; /void outqueue(Linkqueue &Q,Q
5、ueue &e) /此處有點(diǎn)問題? / Qnode *q; /q=(Queue)malloc(sizeof(Qnode); e=Q.front->next; / Q.front->next=q->next;/delete q; Q.front->next=Q.front->next->next; if(Q.rear=e) Q.front=Q.rear; / Q.front=NULL; int QEmpty(Linkqueue Q) if(Q.rear=Q.front) return 0; else return 1;/ /停車場(chǎng)管理操作/void j
6、ixu(Stack L,Linkqueue Q)int n; fflush(stdin); scanf("%d",&n);switch(n)case 1:printf("nn");xunhuan(L,Q); break;case 2:printf("*退出管理系統(tǒng)*n"); break;default:printf("n輸入錯(cuò)誤,請(qǐng)重新輸入: ");jixu(L,Q);break;void jiaofei(float time,float time1,float time2) /繳費(fèi)操作 float dat
7、a1,data2;double money;if(time20!=0&&time21!=0) data2=(time10-time20-1)*60+60-time21+time11;elsedata2=0;data1=(time0-time10-1)*60+60-time11+time1;/printf("進(jìn)入車場(chǎng)時(shí)間%f,退出車場(chǎng)時(shí)間%fn",time11,time1);printf("你的停車時(shí)間為%lf小時(shí) ,在便道停留時(shí)間%f小時(shí)n",data1/60,data2/60); money=data1/60*5.0+data2/60*
8、2.0; printf("請(qǐng)交納%lf元n",money); /* if(data1<=60.0)printf("請(qǐng)交納5元。");if(data1>60.0&&data1<=120.0)printf("請(qǐng)交納10元。");if(data1>120.0)printf("請(qǐng)交納20元。");*/void leave(Stack &L,Linkqueue &Q,int number,float time) /汽車離開操作Stack S;InitStack(S);f
9、loat time12,time22; record e,e1;Queue q; e1=output(L,e); while(e.number!=number) input(S,e1); e1=output(L,e); time10=_time0; /入車站時(shí)間time11=_time1;time20=e.bian_time0; /入便道時(shí)間time21=e.bian_time1; jiaofei(time,time1,time2); / while(StackEmpty(S) input(L,output(S,e1); while(QEmpty(Q)&&S
10、tackman(L) outqueue(Q,q); /printf("nn請(qǐng)輸入汽車從便道進(jìn)入停車場(chǎng)的時(shí)間,輸入格式為(時(shí) 空格 分):"); e.bian_time0=q->int_time0; e.bian_time1=q->int_time1; /scanf("%f %f",&time20,&time21); _time0=time0; _time1=time1; e.number=q->number; printf("n汽車從便道退出進(jìn)入停車場(chǎng)"); printf(&quo
11、t;n請(qǐng)將%d號(hào)車停在%d號(hào)位置!n",e.number,L.top-L.base+1); input(L,e); /void xunhuan(Stack L,Linkqueue Q) /選擇操作及循環(huán)/Queue q; char ch; int number; float time2,time22; fflush(stdin); printf("nA:進(jìn)入停車場(chǎng) D:退出停車場(chǎng) E:退出管理系統(tǒng)n"); printf("n請(qǐng)輸入:"); scanf("%c",&ch);fflush(stdin); switch(c
12、h) case 'A': printf("n請(qǐng)輸入車牌號(hào): "); scanf("%d",&number); printf("請(qǐng)輸入入場(chǎng)時(shí)間,輸入格式為(時(shí) 空格 分):"); scanf("%f %f",&time0,&time1); if(Stackman(L) record e; _time0=time0; _time1=time1; e.bian_time0=0.0; e.bian_time1=0.0; e.number=number; print
13、f("請(qǐng)將車停在%d號(hào)位置!",L.top-L.base+1); input(L,e); else enqueue(Q,number,time); printf("n"); printf("n1、繼續(xù)操作 2、退出操作 : "); jixu(L,Q); break; case 'D': if(StackEmpty(L) printf("請(qǐng)輸入離開汽車的車牌號(hào):"); scanf("%d",&number); printf("輸入汽車離開時(shí)間:"); s
14、canf("%f %f",&time20,&time21); leave(L,Q,number,time2); else printf("停車場(chǎng)為空n"); printf("n1、繼續(xù)操作 2、退出操作 : "); jixu(L,Q); break; case 'E': printf("*退出管理系統(tǒng)*n"); break; default: printf("輸入錯(cuò)誤,請(qǐng)重新輸入!n"); printf("#n"); xunhuan(L,Q); break; /void main() /主函數(shù)操作 Linkqueue Q; Stack L; InitStack(L); Init
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 安全工程試題及答案
- 城市快速路建設(shè)項(xiàng)目2025年社會(huì)穩(wěn)定風(fēng)險(xiǎn)評(píng)估與城市規(guī)劃與社區(qū)互動(dòng)研究報(bào)告
- 工業(yè)互聯(lián)網(wǎng)平臺(tái)入侵檢測(cè)系統(tǒng)2025年數(shù)據(jù)安全防護(hù)方案報(bào)告
- 《庫存管理》課件
- 冬季換季教育培訓(xùn)課件
- 中國(guó)發(fā)展動(dòng)態(tài)課件
- 數(shù)碼影像培訓(xùn)課件
- 周末安全教學(xué)課件
- 員工職業(yè)規(guī)劃課件
- 團(tuán)委培訓(xùn)分享交流
- 航行通告教學(xué)課件
- 2023年護(hù)理考試-外科護(hù)理(副高)歷年考試真題試卷摘選答案
- 2022年廣東高考成績(jī)一分一段表重磅出爐
- 新版病人搬運(yùn)(輪椅)操作評(píng)分標(biāo)準(zhǔn)
- 重癥監(jiān)護(hù)ICU護(hù)理實(shí)習(xí)生出科考試試題及答案
- GB/Z 22074-2008塑料外殼式斷路器可靠性試驗(yàn)方法
- GB/T 32360-2015超濾膜測(cè)試方法
- 中藥學(xué)全套(完整版)課件
- 工程施工停止點(diǎn)檢查表
- 國(guó)開??啤锻鈬?guó)文學(xué)》十年期末考試題庫及答案
- 《滅火器維修》GA95-2015(全文)
評(píng)論
0/150
提交評(píng)論