




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)報(bào)告項(xiàng)目名稱:停車管理系統(tǒng)安徽大學(xué)計(jì)算機(jī)科學(xué)與技術(shù)學(xué)院 姓名:鉏飛祥 學(xué)號(hào):E 專業(yè):軟件工程2016-6-281 .需求分析 1.1問題描述停車場內(nèi)只有一個(gè)可停放n輛汽車的狹長通道,且只有一個(gè)大門可供汽車進(jìn)出。汽車在停車場內(nèi)按車輛到達(dá)時(shí)間的先后順序,依次由北向南排列(大門在最南端,最先到達(dá)的第一輛車停放在停車場的最北端),若車場內(nèi)已停滿n輛汽車,則后來的汽車只能在門外的便道上等候,一旦有車開走,則排在便道上的第一輛車即可開入;當(dāng)停車場內(nèi)某輛車要離開時(shí),在它之后開入的車輛必須先退出車場為它讓路,待該輛車開出大門外,其它車輛再按原次序進(jìn)入車場,
2、每輛停放在車場的車在它離開停車場時(shí)必須按它停留的時(shí)間長短交納費(fèi)用。試為停車場編制按上述要求進(jìn)行管理的模擬程序。 1.2基本要求(1) 輸入的形式和輸入值的范圍;七位字符車牌號(hào) 空格 時(shí)間(12:30)如:A 12:30(2) 輸出的形式;車牌號(hào) 時(shí)間如:A 12:30(3) 程序所能達(dá)到的功能。模擬車子排隊(duì)和進(jìn)出車庫的情況,并且根據(jù)時(shí)間計(jì)費(fèi),隨時(shí)顯示當(dāng)前車庫車輛情況。2. 概要設(shè)計(jì) (1) 數(shù)據(jù)結(jié)構(gòu) 每個(gè)汽車的基本元素:struct car char id8; int h;/*時(shí)*/ int m;/*分*/ struct car *next;棧的基本元
3、素:struct sqstack struct car *base; struct car *top; int stacksize;(2)程序模塊void intstack(struct sqstack &S)/*構(gòu)造棧*/void push_stack(struct sqstack &S,struct car *e)/*e入棧*/void pop_stack(struct sqstack &S,struct car *e)/*出棧頂元素到e*/void creat_q()/*創(chuàng)建隊(duì)列*/void push_q(struct car *p)/*車輛入隊(duì)*/struct
4、car * pop_q()/*車輛出隊(duì)*/void come_in()/*車輛離開*/void go_out()/*車輛進(jìn)入*/void interface()/*主菜單*/(4) 各模塊之間的調(diào)用關(guān)系以及算法設(shè)計(jì)Interface輸入:1230Intstack pushstackCreat_q pushqCome-inGo_outPop_stack pop_qPrintReturn 03. 詳細(xì)設(shè)計(jì)流程圖及模塊調(diào)用如下:開始 創(chuàng)建隊(duì)列,棧 結(jié)束程序主菜單0223輸出車庫車輛21車輛離開車輛進(jìn)入是否在棧中進(jìn)入隊(duì)列棧是否滿是否進(jìn)入棧否是否在隊(duì)列是元素出列顯示費(fèi)用否找不到4. 測試與分析
5、 主界面如下:車庫中假設(shè)最多停三輛車,加入進(jìn)入四輛車abcd,則d需要在便道排隊(duì):此時(shí)若b車開走,顯示費(fèi)用信息,則在便道的d車進(jìn)入車庫:若此時(shí)有車進(jìn)入,則繼續(xù)在便道排隊(duì):5. 附錄源程序清單: #include<stdio.h>#include<stdlib.h>#include<malloc.h>#include<string.h>#define MAX 3 /*宏定義車庫最大車輛*/struct car char id8; int h;/*時(shí)*/ int m;/*分*/ struct car *next;int n=0;/*當(dāng)前車庫內(nèi)的車輛數(shù)
6、*/int m=0;/*當(dāng)前便道的車輛數(shù)*/struct car *p1;struct sqstack struct car *base; struct car *top; int stacksize;struct sqstack S1,S2;void intstack(struct sqstack &S) S.base=(struct car *)malloc(MAX*sizeof(struct car); S.top=S.base; S.stacksize=MAX;void push_stack(struct sqstack &S,struct car *e) strcpy
7、(S.top->id,e->id); S.top->h=e->h; S.top->m=e->m; S.top+;void pop_stack(struct sqstack &S,struct car *e) S.top-; strcpy(e->id,S.top->id); e->h=S.top->h; e->m=S.top->m;void creat_q() p1=(struct car *)malloc(sizeof(struct car); p1->next=NULL;void push_q(struct
8、 car *p) struct car *p2; p2=p1; while(p2->next!=NULL) p2=p2->next; p2->next=p; p->next=NULL;struct car * pop_q() struct car *p; p=p1->next; p1->next=p1->next->next; return p;void come_in() void interface(); printf("請(qǐng)輸入7位車輛車牌號(hào)和進(jìn)入時(shí)間n例如:nA 12:30n"); if(n=MAX) struct ca
9、r *p; p=(struct car*)malloc(sizeof(struct car); scanf("%s",p->id); scanf("%d:%d",&p->h,&p->m); push_q(p); m+; else struct car *p; p=(struct car*)malloc(sizeof(struct car); scanf("%s",p->id); scanf("%d:%d",&p->h,&p->m); push_st
10、ack(S1,p); n+; interface();void go_out() struct car* pop_q(); void interface(); printf("請(qǐng)輸入7位車牌號(hào)和離開時(shí)間n"); char b8; int h1; int m1; scanf("%s",b); scanf("%d:%d",&h1,&m1); int i; int biaozhi=0; for(i=0;i<n;i+) if(strcmp(b,(S1.base+i)->id)=0) printf("%s
11、已離開n計(jì)費(fèi)信息:n進(jìn)入時(shí)間%d:%d,離開時(shí)間%d:%d,(每分鐘1元)n",b,(S1.base+i)->h,(S1.base+i)->m,h1,m1); printf("費(fèi)用為:%d元n",(60*(h1-(S1.base+i)->h)+m1-(S1.base+i)->m)*1); int j; for(j=0;j<n-i;j+) struct car *p2; p2=(struct car *)malloc(sizeof(struct car); pop_stack(S1,p2); push_stack(S2,p2); str
12、uct car *pp; pop_stack(S2,pp); for(j=1;j<n-i;j+) pop_stack(S2,pp); push_stack(S1,pp); printf("222n"); n-; biaozhi=1; if(p1->next!=NULL) /*若便道有車,則便道的車進(jìn)入車庫*/ struct car *ppp; ppp=pop_q(); push_stack(S1,ppp); n+; break; if(biaozhi=0) struct car *p,*pp; pp=p1; while(pp->next!=NULL) p=
13、pp; pp=pp->next; if(strcmp(b,pp->id)=0) printf("%s 已離開n",b); printf("%s 已離開n計(jì)費(fèi)信息:n進(jìn)入時(shí)間%d:%d,離開時(shí)間%d:%d,(每分鐘1元)n",b,pp->h,pp->m,h1,m1); printf("費(fèi)用為:%d元n",(60*(h1-pp->h)+m1-pp->m)*1); p->next=pp->next; m-; biaozhi=1; break; if(biaozhi=0) printf(&quo
14、t;找不到%sn",b); interface();void print() void push_stack(struct sqstack S,struct car *e); void pop_stack(struct sqstack S,struct car *e); void interface(); if(n=0) printf("沒有車輛n"); else printf("*車庫現(xiàn)有車輛信息:n"); int i; for(i=0;i<n;i+) printf(" %s %d:%dn",(S1.base+i)-
15、>id,(S1.base+i)->h,(S1.base+i)->m); struct car *p; p=p1; if(p->next=NULL) printf("*便道無車輛n"); else printf("*便道現(xiàn)有車輛信息:n"); while(p->next!=NULL) p=p->next; printf(" %s %d:%dn",p->id,p->h,p->m); interface();void interface() int i; printf(" 請(qǐng)輸入操作指令nn 1:汽車開入n 2:車輛離開n 3:顯示當(dāng)前車輛信息n 0:結(jié)束程序n*n"); scanf("%d",&i); switch(i) case 0:return ;break; case 1:come_in();break; case 2:go_out();break; case 3:print();break; ;int main() system("color a0"); /可以寫成 red 調(diào)出顏色組 system("title 車庫管理系統(tǒng)"); /設(shè)置cmd窗口標(biāo)題 printf(&qu
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 生物●海南卷丨2024年海南省普通高中學(xué)業(yè)水平選擇性考試生物試卷及答案
- 統(tǒng)編版語文三下( 第三單元重難點(diǎn)梳理)復(fù)習(xí)課件
- 寧夏青銅峽市寧朔縣中2022-2023學(xué)年高二下學(xué)期期末考試化學(xué)試題(含答案)
- 汽車傳感器與檢測技術(shù)電子教案:輪速傳感器
- 售電公司客戶管理制度
- 白玉蘭小區(qū)方案86p
- 商貿(mào)公司門店管理制度
- 從化溪頭破冰活動(dòng)方案
- 倉庫低價(jià)活動(dòng)策劃方案
- 仙湖團(tuán)建活動(dòng)方案
- (2025)紀(jì)檢監(jiān)察業(yè)務(wù)知識(shí)考試題及含答案
- 網(wǎng)絡(luò)安全技術(shù)實(shí)操技能考核試題及答案
- 國家保安員模擬試題及答案(附解析)
- 2025屆廣東省佛山市南海中學(xué)七下數(shù)學(xué)期末學(xué)業(yè)水平測試試題含解析
- DB31/T 1402-2023養(yǎng)老機(jī)構(gòu)認(rèn)知障礙照護(hù)單元設(shè)置和服務(wù)要求
- 湖南省長沙市師大附中教育集團(tuán)2025年數(shù)學(xué)七下期末綜合測試試題含解析
- 血管通路介入治療
- 高速公路養(yǎng)護(hù)安全培訓(xùn)課件
- 軟件知識(shí)產(chǎn)權(quán)授權(quán)管理框架與合規(guī)性研究
- 《分析化學(xué)》期末考試試卷(A)及答案
- 電大漢語言文學(xué)專業(yè)本科社會(huì)實(shí)踐調(diào)查報(bào)告
評(píng)論
0/150
提交評(píng)論