




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
源程序代碼:#include<stdio.h>#include<stdlib.h>#include<iostream.h>#include<time.h>#defineMaxSize5#definefee2#defineL 10000#defineM 20000typedefintElemType;ElemTypetmpnum=0;ElemTypetmptime=0;typedefstruct{ElemTypecar_num[MaxSize];ElemTypecar_time[MaxSize];inttop;}STACK;typedefstructqnode{ElemTypecar_num;ElemTypecar_time;structqnode*next;}QTYPT;typedefstructqptr{QTYPT*front;QTYPT*rear;}SQUEUE;SQUEUELQ;voidInitStack(STACK*S){S->top=-1;)intFull(STACK*S){if(S->top==MaxSize-1){printf("\nStackisfull!Push");return0;)return1;)intPush(STACK*S,ElemTypenum,ElemTypetime){if(S->top==MaxSize-1){printf("\nStackisfull!Push");return0;)S->top++;S->car_num[S->top]=num;S->car_time[S->top]=time;return1;)intEmpty(STACK*S){return(S->top==-1?1:0);)intPop(STACK*S,ElemType*num,ElemType*time){if(Empty(S)){puts("StackisfreePop");return0;)*num=S->car_num[S->top];*time=S->car_time[S->top];S->top—;return1;)intGetTop(STACK*S,ElemType*num,ElemType*time){if(Empty(S)){puts("StackisfreeGettop");)*num=S->car_num[S->top];*time=S->car_time[S->top];return1;)voidInitQueue(SQUEUE*LQ){QTYPT*p=NULL;p=(QTYPT*)malloc(sizeof(QTYPT));p->next=NULL;LQ->front=LQ->rear=p;)intEnQueue(SQUEUE*LQ,ElemTypenum,ElemTypetime){QTYPT*s;s=(QTYPT*)malloc(sizeof(QTYPT));s->car_num=num;s->car_time=time;s->next=LQ->rear->next;LQ->rear->next=s;LQ->rear=s;return1;)intCountQueue(SQUEUE*LQ){inti=1;QTYPT*mfront=NULL;QTYPT*mrear=NULL;mfront=LQ->front;mrear=LQ->rear;while(!(LQ->front==LQ->rear)){i++;LQ->front=LQ->front->next;)LQ->front=mfront;returni;)intEmpty_Q(SQUEUE*LQ){return(LQ->front==LQ->rear?1:0);)intOutQueue(SQUEUE*LQ,ElemType*num,ElemType*time){QTYPT*p;if(Empty_Q(LQ)){puts("QuenueisfreeOutQuenue");return0;)p=LQ->front->next;*num=p->car_num;*time=p->car_time;LQ->front->next=p->next;if(LQ->front->next==NULL)LQ->rear=LQ->front;free(p);return1;)intGetHead(SQUEUE*LQ,ElemType*num,ElemType*time){if(Empty_Q(LQ)){puts("QuenueisfreeGetHead");return0;)*num=LQ->front->next->car_num;*time=LQ->front->next->car_time;return1;)voidsleep(inttime){clock_tgoal;goal=time*(CLOCKS_PER_SEC)+clock();while(goal>clock())(;))intchackinput(STACK*S,intpnum){inti=0;intnum;num=pnum;i=S->top;for(;!(i==-1);i--)if(S->car_num[i]==num)return1;return0;)intchacktime(STACK*S,intptime){returnS->car_time[S->top]<=ptime?1:0;)intdisplaystats(STACK*S,intpinput){voiddisplayhead(void);inti=0;i=S->top;switch(pinput){case10000:(if(!Empty(S))for(;!(i==-1);i--)printf("<===%d時(shí)%d號車停與%d車位===>\n",S->car_time[i],S->car_time[i],i+1);elsecout<<〃停車場為空〃;printf(〃還有車%d個(gè)位\n”,MaxSize-S->topT);break;)case20000:(displayhead();break;)default:(return1;))return0;)voiddisplayhead(void){cout<<'\n'<<〃<===============CT停車場管理系統(tǒng)===================>"<<endl;cout<<〃<==操作說明:*******==>"<<endl;cout<<〃<==A:停車命令*******==>"<<endl;cout<<〃<==D:出車命令***==>"<<endl;cout<<〃<==E:退出程序***==>"<<endl;cout<<〃<==L:顯示停車場內(nèi)狀況〃<<endl;cout<<〃<==============================================>〃<<endl;)voiddisplayChange(STACK*S,ElemTypepnum,intptime){printf(〃(單價(jià)%d元/小時(shí))\n〃,fee);printf(〃<======================電子收據(jù)===================>\n〃);printf(〃<==停車時(shí)間: %d小時(shí)==>\n〃,ptime-tmptime);printf(〃<==車牌號碼: %d==>\n〃,tmpnum);printf(〃<==應(yīng)收費(fèi)用: %d元==>\n〃,(ptime-tmptime)*fee);printf(〃<====================謝謝=歡迎下次再來=============>\n〃);printf(〃正在打印收據(jù)請稍等\n〃);for(intcount=1;count<1;count++){printf(〃二〃);fflush(stdout);sleep(1);printf(〃八n〃);sleep(1);)voidwait(char*string){printf(〃%s\n〃,string);for(intcount=1;count<1;count++){printf(〃-〃);fflush(stdout);sleep(1);)printf(〃八n〃);)intoutparkstation(STACK*S1,STACK*TS,ElemTypepnum){intt_num=0;intt_time=0;while(1){Pop(S1,&t_num,&t_time);if(t_num==pnum){tmpnum=t_num;tmptime=t_time;while(!Empty(TS)){Pop(TS,&t_num,&t_time);Push(S1,t_num,t_time);)return1;)Push(TS,t_num,t_time);)return0;)intinparkstation(STACK*S){intparknum;intparktime;printf(〃還有車%d個(gè)位\n〃,MaxSize-S->top-1);printf(〃請輸入車牌號碼:〃);cin>>parknum;while(chackinput(S,parknum)){printf(〃車牌號碼重復(fù),請輸入%d1或者其他〃,parknum);cin>>parknum;)printf(〃請輸入停車時(shí)間:〃);cin>>parktime;printf("%d號車于%d時(shí)??吭?d位\n”,parknum,parktime,S->top+2);Push(S,parknum,parktime);return1;)intinbiandao(SQUEUE*SQ,STACK*S){intparknum;printf(〃對不起,停車場已滿,請您到便道等待.您將第〃);printf("%d進(jìn)入停車場\n〃,CountQueue(SQ));printf(〃請輸入車牌號碼:〃);cin>>parknum;while(chackinput(S,parknum)){printf(〃車牌號碼重復(fù),請輸入%d1或者其他〃,parknum);cin>>parknum;)EnQueue(SQ,parknum,0);return1;)intOutParkingStation(SQUEUE*biandao,STACK*car,STACK*tmp){intparknum=0;intparktime=0;intbuf=0;if(!Empty(car)){displaystats(car,10000);printf(〃請輸入您要調(diào)出的車牌號碼:〃);cin>>parknum;while(!chackinput(car,parknum)){printf(〃沒有您要的%d的車牌號碼,請輸入正確的車牌號碼:〃,parknum);cin>>parknum;)outparkstation(car,tmp,parknum);printf(〃%d時(shí)%d號車進(jìn)入停車場\n〃,tmptime,tmpnum);printf(〃請輸入現(xiàn)在的時(shí)間:〃);cin>>parktime;while(!chacktime(car,parktime)){cout<<〃輸入時(shí)間小于停車時(shí)間,請重新輸入:〃;cin>>parktime;)displayChange(car,parknum,parktime);if(biandao->front==biandao->rear){)else(printf("%d號車位空開\口〃,。2)乂0口+2);printf(〃%d時(shí)便道上的%d號汽車駛?cè)耄號車位”,parktime,biandao->front->next->car_num,car->top+2);OutQueue(biandao,&parknum,&buf);Push(car,parknum,parktime);)return2;)printf(〃停車場為空\口〃);return1;);intmain(intargc,char*agv口){charchance='A';STACKcar;InitStack(&car);STACKtmp;InitStack(&tmp);SQUEUEbiandao;InitQueue(&biandao);loop:while(1){displayhead();cout<<〃=>:〃;cin>>chance;switch(chance){case'A':(wait(〃正在查詢車位,請稍等:〃);if(Full(&car))inparkstation(&car)
溫馨提示
- 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 陜西省西安市新城區(qū)2024-2025學(xué)年八年級上學(xué)期期末生物學(xué)試題(含答案)
- 投資理財(cái)借款合同
- 城市公園建設(shè)與管理合作協(xié)議
- 教育培訓(xùn)領(lǐng)域在線教育平臺內(nèi)容優(yōu)化策略研究
- 客戶關(guān)系管理解決方案實(shí)施報(bào)告
- 農(nóng)業(yè)產(chǎn)業(yè)鏈延伸作業(yè)指導(dǎo)書
- 干砌擋土墻現(xiàn)場質(zhì)量檢驗(yàn)報(bào)告單
- 國際貿(mào)易術(shù)語題庫
- 院感知識崗前培訓(xùn)
- 特色漁業(yè)資源經(jīng)營合同
- 《建筑電氣設(shè)計(jì)》課件
- 品管圈PDCA案例-介入中心提高手術(shù)患者交接記錄書寫合格率醫(yī)院品質(zhì)管理成果匯報(bào)
- 第十七屆山東省職業(yè)院校技能大賽中職組“西式烹飪”賽項(xiàng)規(guī)程
- 華東師范大學(xué)《外國人文經(jīng)典(下)》2022-2023學(xué)年第一學(xué)期期末試卷
- 儲能電池模組PACK和系統(tǒng)集成項(xiàng)目可行性研究報(bào)告
- 2024年安徽省公務(wù)員錄用考試《行測》真題及解析
- 牙慢性損傷-楔狀缺損
- JTJ034-2000 公路路面基層施工技術(shù)規(guī)范
- 2024-2030年中國光伏建筑一體化(BIPV)市場規(guī)模預(yù)測與競爭格局分析研究報(bào)告
- 零售業(yè)視覺營銷與商品展示技巧考核試卷
- 民營醫(yī)院并購合同范本
評論
0/150
提交評論