停車(chē)場(chǎng)實(shí)驗(yàn)報(bào)告_第1頁(yè)
停車(chē)場(chǎng)實(shí)驗(yàn)報(bào)告_第2頁(yè)
停車(chē)場(chǎng)實(shí)驗(yàn)報(bào)告_第3頁(yè)
停車(chē)場(chǎng)實(shí)驗(yàn)報(bào)告_第4頁(yè)
停車(chē)場(chǎng)實(shí)驗(yàn)報(bào)告_第5頁(yè)
已閱讀5頁(yè),還剩5頁(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)介

停車(chē)場(chǎng)模擬管理系統(tǒng)實(shí)驗(yàn)報(bào)告班級(jí):數(shù)學(xué)三班姓名:劉國(guó)華學(xué)號(hào):2007429086日期:2008-1需求分析:程序功能:用順序棧模擬停車(chē)位和輔助棧,用順序隊(duì)模擬便道。來(lái)車(chē)顯示停車(chē)位置,離車(chē)顯示車(chē)輛調(diào)度情況及應(yīng)交的停車(chē)費(fèi),還能查詢(xún)特定車(chē)牌號(hào)的汽車(chē)所在的位置。輸入輸出要求:C,L,F,Q分別表示來(lái)車(chē),離車(chē),查詢(xún)車(chē),退出;來(lái)車(chē)時(shí)輸入車(chē)牌號(hào),走時(shí)輸入所在停車(chē)位的位置,查詢(xún)輸入車(chē)牌號(hào);測(cè)試數(shù)據(jù):來(lái)車(chē):JE001到JE010查詢(xún):JE003,JE008離車(chē):JE001,JE007退出概要設(shè)計(jì):本程序所用的抽象數(shù)據(jù)類(lèi)型定義:順序棧,順序隊(duì);主模塊的流程及個(gè)子模塊的主要功能:STOPPING*init_stopping()初始化停位BUFFER*init_buff()初始化輔助棧PAVEMENT*init_pavement()初始化便道voidcar_come(char*plate,char*in_time)來(lái)車(chē)函數(shù)voidcar_leave(intpos,char*out_time)離車(chē)函數(shù)voidstop_to_buff(intpos)從停車(chē)位進(jìn)入輔助棧函數(shù)voidbuff_to_stop(intpos)從輔助棧進(jìn)入停車(chē)位函數(shù)voidpave_to_stop()從便道進(jìn)入停車(chē)位函數(shù)floatcheckout(char*in_time,char*out_time)計(jì)算停車(chē)費(fèi)函數(shù)voidwelcome()歡迎函數(shù)voiddisplay()顯示停車(chē)場(chǎng)情況的函數(shù)voidshow_car(char*plate)查詢(xún)并顯示汽車(chē)信息的函數(shù)voidmain()主函數(shù)詳細(xì)設(shè)計(jì):采用C語(yǔ)言定義停車(chē)位、輔助棧、便道:(1)STOPPING*init_stopping()/*初始化停車(chē)位*/{ STOPPING*s; s=(STOPPING*)malloc(sizeof(STOPPING)); if(!s) { printf("STOPPING空間不足!"); returnNULL; } else { s->top=-1;returns; }}(2)BUFFER*init_buff()/*初始化輔助棧*/{ BUFFER*b; b=(BUFFER*)malloc(sizeof(BUFFER)); if(!b) { printf("BUFFER空間不足!"); returnNULL; } else { b->top=-1; returnb; }}(3)PAVEMENT*init_pavement()/*初始化便道*/{ PAVEMENT*p; p=(PAVEMENT*)malloc(sizeof(PAVEMENT)); p->front=p->rear=MAX_PAVE-1; returnp;}主要功能模塊的偽碼算法:voidcar_come(char*plate,char*in_time){If(停車(chē)為未滿)來(lái)車(chē)進(jìn)入停車(chē)位;Else來(lái)車(chē)進(jìn)入便道等候;}voidcar_leave(intpos,char*out_time){輸入汽車(chē)所在位置;If(汽車(chē)不在最后一個(gè)車(chē)位)stop_to_buff(intpos);所選汽車(chē)離去;顯示應(yīng)繳費(fèi)用;If(輔助棧不空)buff_to_stop(intpos);if(便道不空)pave_to_stop();}voidshow_car(char*plate){遍歷停車(chē)位,如找到所查汽車(chē)則停止;If(停車(chē)位無(wú)此車(chē))遍歷便道,如找到停止;if(便道無(wú)此車(chē))顯示信息無(wú)此車(chē);}Welcome()Welcome()Stop_to_buff()Stop_to_buff()Display()Display()BBuff_to_stop()Main()Car_leave()Main()Car_leave()Pave_to_stop()Pave_to_stop()CCar_come()CCheckout()SShow_car()調(diào)試分析:調(diào)試中的問(wèn)題及解決方法:各函數(shù)無(wú)法都作用于順序隊(duì)和順序棧,解決方法:將順序隊(duì)和順序棧定義成全局變量;無(wú)法將輸入的字符指針char*plate接收的車(chē)牌號(hào)字符串傳遞給各函數(shù),解決方法:在給plate輸入前給plate開(kāi)辟空間plate=(char*)malloc(sizeof(char));無(wú)法將字符串型的時(shí)間逐個(gè)轉(zhuǎn)換成整型,解決方法:定義字符型指針,逐一指向字符串中的每個(gè)字符;使用說(shuō)明及測(cè)試結(jié)果:使用說(shuō)明:輸入C(L、F、Q)表示來(lái)車(chē)(離車(chē)、查詢(xún)、退出),接下來(lái)按照提示輸入;測(cè)試結(jié)果:來(lái)車(chē):請(qǐng)選擇您要的操作:c請(qǐng)輸入您的車(chē)牌號(hào):JE001請(qǐng)輸入您的入場(chǎng)時(shí)間:10:10請(qǐng)您停放在1號(hào)車(chē)位!您的入場(chǎng)時(shí)間為:10:10停車(chē)位的情況:1車(chē)位——JE001(2)離車(chē):請(qǐng)選擇您要的操作:L請(qǐng)輸入您的汽車(chē)所在停車(chē)位的車(chē)位數(shù):1請(qǐng)輸入您的離場(chǎng)時(shí)間:10:40牌照為JE003的汽車(chē)暫時(shí)退出停車(chē)位!牌照為JE002的汽車(chē)暫時(shí)退出停車(chē)位!拍照為JE001的汽車(chē)從停車(chē)場(chǎng)開(kāi)走!請(qǐng)交費(fèi)3.0元!牌照為JE002的汽車(chē)停回停車(chē)位的1車(chē)位!牌照為JE003的汽車(chē)?;赝\?chē)位的2車(chē)位!停車(chē)位的情況:1車(chē)位——JE0022車(chē)位——JE003(3)請(qǐng)選擇您要的操作:F請(qǐng)輸入您要查找的車(chē)牌號(hào):JE002您的汽車(chē)JE002位于停車(chē)位的1車(chē)位!源程序:#include"stdio.h"#include"stdlib.h"#include"string.h"#defineMAX_STOP5/*停車(chē)位*/#defineMAX_PAVE100/*便道位*/typedefstruct{ char*license_plate;/*車(chē)牌號(hào)*/ char*in_time;/*進(jìn)入停車(chē)場(chǎng)的時(shí)間*/ char*out_time;/*離開(kāi)停車(chē)場(chǎng)的時(shí)間*/ charstate;/*狀態(tài),S表示停車(chē)位,P表示便道,L表示離開(kāi)*/}CAR;typedefstruct/*定義停車(chē)為類(lèi)型*/{ CARSTOP[MAX_STOP]; inttop;}STOPPING;typedefstruct/*定義便道類(lèi)型*/{ CARPAVE[MAX_PAVE]; intfront,rear;}PAVEMENT;typedefstruct/*定義輔助棧類(lèi)型*/{ CARBUFF[MAX_STOP]; inttop;}BUFFER;STOPPING*init_stopping()/*初始化停車(chē)位*/{ STOPPING*s; s=(STOPPING*)malloc(sizeof(STOPPING)); if(!s) { printf("STOPPING空間不足!"); returnNULL; } else { s->top=-1;returns; }}BUFFER*init_buff()/*初始化輔助棧*/{ BUFFER*b; b=(BUFFER*)malloc(sizeof(BUFFER)); if(!b) { printf("BUFFER空間不足!"); returnNULL; } else { b->top=-1; returnb; }}PAVEMENT*init_pavement()/*初始化便道*/{ PAVEMENT*p; p=(PAVEMENT*)malloc(sizeof(PAVEMENT)); p->front=p->rear=MAX_PAVE-1; returnp;}staticSTOPPING*stopping=init_stopping();/*定義停車(chē)位*/staticBUFFER*buff=init_buff();/*定義輔助棧*/staticPAVEMENT*pavement=init_pavement();/*定義便道*/voidcar_come(char*plate,char*in_time)/*來(lái)車(chē)函數(shù)*/{ if(stopping->top!=MAX_STOP-1) { stopping->top++; stopping->STOP[stopping->top].license_plate=plate; stopping->STOP[stopping->top].in_time=in_time;stopping->STOP[stopping->top].state='S'; printf("請(qǐng)您停放在%d號(hào)車(chē)位!您的入場(chǎng)時(shí)間為:%s\n",stopping->top+1,stopping->STOP[stopping->top].in_time); } else { pavement->rear=(pavement->rear+1)%MAX_PAVE; pavement->PAVE[pavement->rear].license_plate=plate; pavement->PAVE[pavement->rear].in_time=in_time;pavement->PAVE[pavement->rear].state='P'; printf("停車(chē)位已滿!請(qǐng)?jiān)诒愕赖却?!您的入?chǎng)時(shí)間為:%s\n",pavement->PAVE[pavement->rear].in_time); }}voidstop_to_buff(intpos)/*暫入輔助棧函數(shù)*/{buff->top++; buff->BUFF[buff->top].license_plate=stopping->STOP[pos].license_plate; buff->BUFF[buff->top].in_time=stopping->STOP[pos].in_time; stopping->top--; printf("牌照為%s的汽車(chē)暫時(shí)退出停車(chē)位!\n",stopping->STOP[pos].license_plate);}voidbuff_to_stop(intpos)/*由輔助棧返回停車(chē)位函數(shù)*/{ stopping->top++;stopping->STOP[pos].license_plate=buff->BUFF[buff->top].license_plate; stopping->STOP[pos].in_time=buff->BUFF[buff->top].in_time;stopping->STOP[pos].state='S';buff->top--; printf("牌照為%s的汽車(chē)停回停車(chē)位的%d車(chē)位!\n",stopping->STOP[pos].license_plate,pos+1);}voidpave_to_stop()/*由便道進(jìn)入停車(chē)位函數(shù)*/{ stopping->top++; pavement->front=(pavement->front+1)%MAX_PAVE;stopping->STOP[stopping->top].license_plate=pavement->PAVE[pavement->front].license_plate; stopping->STOP[stopping->top].in_time=pavement->PAVE[pavement->front].in_time;stopping->STOP[stopping->top].state='S'; printf("牌照為%s的汽車(chē)從便道上進(jìn)入停車(chē)位的%d車(chē)位!\n",pavement->PAVE[pavement->front].license_plate,MAX_STOP);}floatcheckout(char*in_time,char*out_time)/*記時(shí)收費(fèi)函數(shù)*/{ intsum1=0,sum2=0; char*a,*b; a=in_time; b=out_time; sum1+=(*(a+4)-'0')+(*(a+3)-'0')*10; sum1+=((*(a+1)-'0')+(*a-'0')*10)*60;sum2+=(*(b+4)-'0')+(*(b+3)-'0')*10; sum2+=((*(b+1)-'0')+(*b-'0')*10)*60;return((sum2-sum1)*0.1);}voidcar_leave(intpos,char*out_time)/*離車(chē)函數(shù)*/{ inta=pos; intb=a-1; intc,d; floatmoney; money=checkout(stopping->STOP[b].in_time,out_time); if(a>MAX_STOP||a<1) { printf("車(chē)位號(hào)只能是1——5,請(qǐng)重新輸入!");scanf("%d",&a); car_leave(a,out_time); return; } if(b!=stopping->top) { for(c=stopping->top;c>b;c--)stop_to_buff(c); d=buff->top; }stopping->top--; printf("牌照為%s的汽車(chē)從停車(chē)場(chǎng)開(kāi)走!請(qǐng)交費(fèi)%f元!\n",stopping->STOP[b].license_plate,money); if(buff->top!=-1) {for(c=b;c<=b+d;c++) buff_to_stop(c); } if(pavement->front!=pavement->rear) pave_to_stop();}voidwelcome()/*歡迎界面*/{ printf("\n●歡迎使用本程序●\n\n"); printf("本程序?yàn)橥\?chē)場(chǎng)的模擬管理程序,有車(chē)到來(lái)時(shí)請(qǐng)按C(或c)鍵。\n"); printf("然后根據(jù)屏幕提示進(jìn)行相關(guān)操作,有車(chē)要走時(shí)請(qǐng)按L(或l)鍵。\n");printf("然后根據(jù)屏幕提示進(jìn)行相關(guān)操作,查找汽車(chē)時(shí)請(qǐng)按F(或f)鍵。\n");printf("然后根據(jù)屏幕提示進(jìn)行相關(guān)操作,要退出程序請(qǐng)按Q(或q)鍵。\n\n\n");}voiddisplay()/*顯示停車(chē)場(chǎng)情況函數(shù)*/{ inti=0,j; intk=1;/*表示便道位置*/ if(stopping->top==-1) printf("停車(chē)位上暫無(wú)車(chē)輛!\n\n"); else { printf("停車(chē)位的情況:\n"); while(i<=stopping->top) { printf("%d車(chē)位——%s\n",i+1,stopping->STOP[i].license_plate); i++; } if(pavement->front!=pavement->rear) { j=(pavement->front+1)%MAX_PAVE; printf("便道上的情況:\n"); while(j<=pavement->rear) { printf("%d位置——%s\n",k,pavement->PAVE[j].license_plate); j++; k++; } } printf("\n"); }}voidshow_car(char*plate)/*查找并顯示信息函數(shù)*/{ inti,j; for(i=0;i<=stopping->top;i++) if(!strcmp(stopping->STOP[i].license_plate,plate))break; if(i==stopping->top+1) { for(j=(pavement->front+1)%MAX_PAVE;j<=pavement->rear;j++) if(!strcmp(pavement->PAVE[j].license_plate,plate))break; } if(i<stopping->top+1) printf("您的汽車(chē)%s位于停車(chē)位的%d車(chē)位!\n\n",plate,i+1); else { if(j<pavement->rear+1) printf("您的汽車(chē)位于便道的%d位置!\n\n",j-(pavement->front+1)%MAX_PAVE+1); else printf("對(duì)不起,停車(chē)場(chǎng)中無(wú)此車(chē)!\n\n"); }}voidmain(){ charkey; char*plate,*in_time,*out_time; int

溫馨提示

  • 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)論