九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

C數(shù)據(jù)結(jié)構(gòu) 大作業(yè)課程設(shè)計(jì)

上傳人:ca****in 文檔編號(hào):113981538 上傳時(shí)間:2022-06-27 格式:DOC 頁(yè)數(shù):131 大小:879KB
收藏 版權(quán)申訴 舉報(bào) 下載
C數(shù)據(jù)結(jié)構(gòu) 大作業(yè)課程設(shè)計(jì)_第1頁(yè)
第1頁(yè) / 共131頁(yè)
C數(shù)據(jù)結(jié)構(gòu) 大作業(yè)課程設(shè)計(jì)_第2頁(yè)
第2頁(yè) / 共131頁(yè)
C數(shù)據(jù)結(jié)構(gòu) 大作業(yè)課程設(shè)計(jì)_第3頁(yè)
第3頁(yè) / 共131頁(yè)

下載文檔到電腦,查找使用更方便

40 積分

下載資源

還剩頁(yè)未讀,繼續(xù)閱讀

資源描述:

《C數(shù)據(jù)結(jié)構(gòu) 大作業(yè)課程設(shè)計(jì)》由會(huì)員分享,可在線閱讀,更多相關(guān)《C數(shù)據(jù)結(jié)構(gòu) 大作業(yè)課程設(shè)計(jì)(131頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。

1、C+/數(shù)據(jù)結(jié)構(gòu) 大作業(yè)/課程設(shè)計(jì)【校園導(dǎo)游咨詢】【停車(chē)場(chǎng)管理】娃娃們可以收著以后用 絕對(duì)純手工打造 內(nèi)含類(lèi)模塊/一維指針數(shù)組(謹(jǐn)以此程序供大家參考。運(yùn)行結(jié)果后面有貼圖)目錄【1】校園導(dǎo)游咨詢 程序設(shè)計(jì)源代碼 及 截圖【2】停車(chē)場(chǎng)管理方案一 程序設(shè)計(jì)源代碼 及 截圖【3】停車(chē)場(chǎng)管理方案二 程序設(shè)計(jì)源代碼 及 截圖#【1】【校園導(dǎo)游咨詢】#(ps:該校園導(dǎo)游咨詢系統(tǒng)沒(méi)有輸入值,所有信息是都在class MGraph的構(gòu)造函數(shù)中傳輸?shù)?,且校園景點(diǎn)信息皆為【上海電力學(xué)院】景點(diǎn)信息。請(qǐng)大家注意,直接從文章copy到visual stutio中會(huì)出現(xiàn)中文字符,注意刪除,推薦大家在一行語(yǔ)句的分號(hào)后面,點(diǎn)出光

2、標(biāo),按一下delete鍵,然后按一下enter鍵,完成visual stutio的自動(dòng)對(duì)齊,這樣程序看起來(lái)一目了然,更易于操作和更改)【問(wèn)題描述】設(shè)計(jì)一個(gè)校園導(dǎo)游程序,為來(lái)訪的客人提供各種信息查詢服務(wù)?!净疽蟆?1)設(shè)計(jì)你所在學(xué)校的校園平面圖,所含景點(diǎn)不少于10個(gè)。以圖中頂點(diǎn)表示校內(nèi)各景點(diǎn),存放景點(diǎn)名稱(chēng)、代號(hào)、簡(jiǎn)介等信息;以邊表示路徑,存放路徑長(zhǎng)度等相關(guān)信息。(2)為來(lái)訪客人提供圖中任意景點(diǎn)相關(guān)信息的查詢。(3)為來(lái)訪客人提供圖中任意景點(diǎn)的問(wèn)路查詢,即查詢?nèi)我鈨蓚€(gè)景點(diǎn)之間的一個(gè)最短的簡(jiǎn)單路徑?!具x作內(nèi)容】(6)擴(kuò)充每個(gè)景點(diǎn)的鄰接景點(diǎn)的方向等信息,使得路徑查詢結(jié)果能提供詳盡的導(dǎo)向信息。*【以

3、下為類(lèi)的定義】*#include#includeusing namespace std;const int MaxSize=18;const int INFINITY=65535;/最大值無(wú)窮class direction;template class MGraph;template class VertexNode/定義頭結(jié)點(diǎn)friend class MGraph; public:int vex;/頂點(diǎn)名稱(chēng)T vexname;/頂點(diǎn)名稱(chēng)T vexinf;/頂點(diǎn)信息direction dir;/存放頂點(diǎn)方位信息的direction類(lèi)的dir。;class directionpublic:int

4、 ln;/存放在方向圖中的橫坐標(biāo),表示東西int col;/存放在方向圖中的縱坐標(biāo),表示南北;template class MGraph/定義無(wú)向圖的鄰接矩陣public:MGraph(); /構(gòu)造函數(shù),初始化具有n個(gè)頂點(diǎn)的圖void printvexname();/顯示所有景點(diǎn)及景點(diǎn)代號(hào)void printvexinf(int i);/顯示代號(hào)為i景點(diǎn)的名稱(chēng)及信息void printroad(int i,int j);/顯示景點(diǎn)ij的最短路徑方案信息void printdir(int i,int j);/顯示景點(diǎn)i到j(luò)的方向信息,如“向東100m,向南200m”VertexNode adjl

5、istMaxSize; /存放景點(diǎn)全部信息的 景點(diǎn)類(lèi)數(shù)組int vertexNum,arcNum; /圖的頂點(diǎn)數(shù)和邊數(shù)void Root(int p,int q);/遞歸尋找pq間的最短路徑int PathMaxSizeMaxSize,DistMaxSizeMaxSize;/創(chuàng)建Path和Dist分別存放兩點(diǎn)間最短路徑的前驅(qū)節(jié)點(diǎn),兩點(diǎn)間最短路徑長(zhǎng)度int LineMaxSize;/Line存放路徑int kkk;/Line數(shù)組的標(biāo)記private:T vertexMaxSize; /存放圖中頂點(diǎn)的數(shù)組int arcMaxSizeMaxSize;/存放圖中邊的數(shù)組;*【以下為類(lèi)的實(shí)現(xiàn) 即類(lèi)函數(shù)的

6、定義】*template MGraph:MGraph()/a為景點(diǎn)代號(hào),b為景點(diǎn)名稱(chēng),c為景點(diǎn)信息,d為景點(diǎn)方位信息的橫坐標(biāo),e為景點(diǎn)方位信息的縱坐標(biāo)/s為存放景點(diǎn)鄰接矩陣信息的一維數(shù)組,根據(jù)其對(duì)稱(chēng)性可以用公式賦值給二維數(shù)組arcint s=0,1,0,0,2,0,0,0,2,0,0,0,2,3,0,0,0,0,4,2,0,0,0,0,0,2,3,0,0,0,0,0,2,3,1,0,0,0,2,0,2,0,0,2,0,4,0,2,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,2,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,3,0,0

7、,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,0,2,0;int a=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17;char* b=南門(mén),實(shí)驗(yàn)樓,南圖,大活,睿思樓,大禮堂,南4教,知行樓,國(guó)交樓,南3教,南2教,南1教,北圖,北3教,北4教,北2教,北1教,北門(mén);char* c=南校區(qū)正

8、門(mén),物理實(shí)驗(yàn)樓,南校區(qū)圖書(shū)館,大學(xué)生活動(dòng)中心,教師辦公樓、醫(yī)務(wù)室及留學(xué)生公寓,大禮堂,用于舉辦各種文藝演出,南校區(qū)第4教學(xué)樓,實(shí)習(xí)基地,計(jì)算機(jī)房等,國(guó)際交流中心,教職工餐廳,南校區(qū)第3教學(xué)樓,南校區(qū)第2教學(xué)樓,南校區(qū)第1教學(xué)樓,北校區(qū)圖書(shū)館,北校區(qū)第3教學(xué)樓,北校區(qū)第4教學(xué)樓,北校區(qū)第2教學(xué)樓,北校區(qū)第1教學(xué)樓,北校區(qū)正門(mén);int d=8,6,4,4,1,0,0,1,3,4,6,8,4,3,2,3,5,8;int e=8,8,8,10,8,10,7,6,6,6,6,6,3,1,0,0,0,2;int i,j;vertexNum=18;arcNum=30; for(i=0;ivertexNum;

9、i+)adjlisti.vex=ai;adjlisti.vexname=bi;adjlisti.vexinf=ci;adjlisti.dir.ln=di;adjlisti.dir.col=ei;for (i=0; ivertexNum; i+)/初始化鄰接矩陣for (j=0; jvertexNum; j+)arcij=arcji=s(i*(i+1)/2+j; /根據(jù)s的對(duì)稱(chēng)性,將一維數(shù)組中的數(shù)據(jù)賦給二維數(shù)組arc templatevoid MGraph:printvexname()int i;for(i=0;ivertexNum;i+)coutadjlisti.vex adjlisti.ve

10、xnameendl;templatevoid MGraph:printvexinf(int i)couti adjlisti.vexname:adjlisti.vexinfendl;templatevoid MGraph:printdir(int i,int j)int dx,nb;/臨時(shí)存放i與j之間的南北東西關(guān)系 j在i的哪邊?dx=adjlistj.dir.col-adjlisti.dir.col;nb=adjlistj.dir.ln-adjlisti.dir.ln;if(dx0)/即j在i的東邊cout向東dx*100m,;elsecout向西dx*(0-100)0)/即j在i的南邊c

11、out向南nb*100m;elsecout向北nb*(0-100)m;templatevoid MGraph:Root(int p,int q) if (Pathpq0) Root(p,Pathpq); Root(Pathpq,q); else Linekkk=q; kkk+; templatevoid MGraph:printroad(int i,int j)int p,q,m,k,item1,item2;for(p=0;pvertexNum;p+)for(q=0;qvertexNum;q+)Distpq=arcpq;/鄰接矩陣賦值for(k=0;kvertexNum;k+) for(p=0

12、;p0) for(q=0;q0) if (DistpqDistpk+Distkq)|(Distpq=0)&(p!=q) Distpq=Distpk+Distkq; Pathpq=k; coutn=n;cout從adjlisti.vexname到adjlistj.vexname的最短路徑為:endl;coutadjlisti.vexname;kkk=2;Root(i,j);item2=Line2;cout;printdir(i,item2);coutadjlistitem2.vexname;for(m=3;m=kkk-1;m+)item1=Linem;cout;printdir(item1-1,

13、item1);coutadjlistitem1.vexname;coutendl;coutn=n;*【以下為主函數(shù)】*int funcchoice()/系統(tǒng)功能選擇頁(yè)面int choice;cout=endl;cout 歡迎進(jìn)入校園導(dǎo)游咨詢平臺(tái)endl;cout 1-顯示校園所有景點(diǎn)信息endl;cout 2-查詢校園景點(diǎn)信息endl;cout 3-問(wèn)路查詢系統(tǒng)endl;cout 4-退出導(dǎo)游資訊平臺(tái)endl;cout=endl;coutchoice;return choice;void main()MGraph mg;int funcchoice();int fc;while(1)fc=fu

14、ncchoice();if(fc=1)int i;for(i=0;img.vertexNum;i+)mg.printvexinf(i);else if(fc=2)int i;mg.printvexname();coutendli;mg.printvexinf(i);else if(fc=3)int i,j;mg.printvexname();coutij;mg.printroad(i,j);else if(fc=4)break;elsecout輸入有誤,請(qǐng)重新輸入!endl;運(yùn)行測(cè)試圖#【2】【停車(chē)場(chǎng)管理系統(tǒng)【方案一 程序】#(ps:該程序有漏洞,若將要離開(kāi)的車(chē)輛是停于便道上的,則對(duì)該車(chē)進(jìn)行駛

15、離操作時(shí)程序內(nèi)部有錯(cuò)誤數(shù)據(jù),雖然做了函數(shù)完成這一功能,但因時(shí)間有限,沒(méi)能及時(shí)查找更正,現(xiàn)在懶得改了。大家將就看吧。不過(guò)運(yùn)行是可以的)【問(wèn)題描述】設(shè)停車(chē)場(chǎng)是一個(gè)可停放n輛汽車(chē)的 長(zhǎng)通道,且只有一個(gè)大門(mén)可供汽車(chē)進(jìn)出。汽車(chē)在停車(chē)場(chǎng)內(nèi)按車(chē)輛到達(dá)時(shí)間的先后順序,依次由北向南排列(大門(mén)在最南端,最先到達(dá)的第一輛車(chē)信放在車(chē)場(chǎng)的最北端),若車(chē)場(chǎng)內(nèi)已停滿n輛汽車(chē),則后來(lái)的汽車(chē)只能在門(mén)外的便道上等候,一旦有車(chē)開(kāi)走,則排在便道上的第一輛車(chē)即可開(kāi)入;當(dāng)停車(chē)場(chǎng)內(nèi)某輛車(chē)要離開(kāi)時(shí),在它之后進(jìn)入的車(chē)輛必須先退出車(chē)場(chǎng)為它讓路,待該輛車(chē)開(kāi)出大門(mén)外,其他車(chē)輛再按原次序進(jìn)入車(chē)場(chǎng)院,每輛停放在車(chē)場(chǎng)的車(chē)在它離開(kāi)停車(chē)場(chǎng)時(shí)必須按它停留的時(shí)間

16、長(zhǎng)短交納費(fèi)用。試為停車(chē)場(chǎng)編制按上述要求進(jìn)行管理的模擬程序?!净疽蟆恳詶DM停車(chē)場(chǎng),以隊(duì)列模擬車(chē)場(chǎng)外的便道,按照從終端讀入的輸入數(shù)據(jù)序列進(jìn)行模擬管理。每一組輸入數(shù)據(jù)包括三個(gè)數(shù)據(jù)項(xiàng):汽車(chē)“到達(dá)”或“離去”信息、汽車(chē)牌照號(hào)碼以及到達(dá)或離去的時(shí)刻。對(duì)每一組輸入數(shù)據(jù)進(jìn)行操作后的輸出信息為:若是車(chē)輛到達(dá),則輸出汽車(chē)在停車(chē)場(chǎng)內(nèi)或便道上的停車(chē)位置;若是車(chē)輛離去,則輸出汽車(chē)在停車(chē)場(chǎng)內(nèi)停留的時(shí)間和應(yīng)交納的費(fèi)用(在便道上停留的時(shí)間不收費(fèi))。棧以順序結(jié)構(gòu)實(shí)現(xiàn),隊(duì)列以鏈表結(jié)構(gòu)實(shí)現(xiàn)?!緶y(cè)試數(shù)據(jù)】設(shè)n=2,輸入數(shù)據(jù)為:(A,1,5),(A,2,15),(A,3,20),(A,4,25),(A,5,30),(D,2,35

17、),(D,4,40),(E,0,0)。其中:A表示到達(dá)(Arrival);D表示離去(Departure);E表示輸入結(jié)束(End)。*【以下為類(lèi)的定義】*#includeusing namespace std;const int Max=2;/車(chē)庫(kù)最大容量const double price=30;/每小時(shí)的費(fèi)用/思想:(報(bào)告第四頁(yè))/我的系統(tǒng)界面,輸入信息為:(到達(dá)/離開(kāi)/退出);車(chē)牌號(hào);時(shí)刻/因此,我的停車(chē)場(chǎng)類(lèi)分成車(chē)輛到達(dá)和車(chē)輛離開(kāi)兩個(gè)主要的函數(shù)實(shí)現(xiàn)。/車(chē)輛到達(dá),有入棧和入隊(duì)。車(chē)輛離開(kāi)有出棧,出隊(duì)和入棧操作。/因此我又編寫(xiě)入棧的類(lèi),隊(duì)的類(lèi)。與parkingmanagement進(jìn)行友元。/

18、*類(lèi)定義*class car/車(chē)的信息類(lèi)public:double time;/計(jì)費(fèi)時(shí)間int number;/車(chē)牌號(hào)car *next;/存放car類(lèi)型元素的數(shù)組初始地址;class carstack/棧(停車(chē)場(chǎng))的類(lèi)friend class parkingmanagement;/parkingmanagement能訪問(wèn)carstack類(lèi)中所有成員public:carstack();/構(gòu)造函數(shù),棧的初始化int empty();/判斷棧是否為空int full();/判斷棧是否為滿car *s;/存放car類(lèi)型棧元素的數(shù)組初始地址int top;/棧頂指針;class carqueue/隊(duì)列

19、(便道)的類(lèi)friend class parkingmanagement;/parkingmanagement能訪問(wèn)carstack類(lèi)中所有成員public:carqueue();/構(gòu)造函數(shù),隊(duì)列的初始化int full();/判斷隊(duì)列是否為滿car *front,*rear;/存放car類(lèi)型隊(duì)列元素的數(shù)組初始地址;class parkingmanagementpublic:int pushstack(carstack &cs,int cnum,double ctime);/入棧,cs棧內(nèi)進(jìn)行調(diào)整,返回棧內(nèi)位置void popstack(carstack &cs,int cnum);/出棧,c

20、s棧內(nèi)進(jìn)行調(diào)整,/根據(jù)車(chē)牌號(hào)把車(chē)彈出棧,將出棧car的number賦值給int popstacknumber()/將出棧car的time賦值給double popstacktime(),無(wú)返回值!int pushqueue(carqueue &cq,int cnum,double ctime);/入隊(duì),隊(duì)內(nèi)進(jìn)行調(diào)整,返回隊(duì)內(nèi)位置int popqueue(carqueue &cq);/出隊(duì),隊(duì)內(nèi)進(jìn)行調(diào)整,返回汽車(chē)車(chē)牌號(hào)void arrival(carstack &cs,carqueue &cq,int cnum,double ctime);/車(chē)輛到達(dá),/根據(jù)輸入的車(chē)牌號(hào)、到達(dá)時(shí)間,變更函數(shù)參數(shù);

21、并cout車(chē)位信息void leave(carstack &cs,carqueue &cq,int cnum,double ctime);/車(chē)輛離開(kāi),/根據(jù)輸入的車(chē)牌號(hào)找到汽車(chē),并進(jìn)行出棧操作、出隊(duì)操作和入棧操作;/并cout停留時(shí)間和收費(fèi)情況void deletequeue(carqueue &cq,int i);/刪除cq過(guò)道中第i輛車(chē)int popstacknumber;/專(zhuān)門(mén)存放出棧的時(shí)候返回的車(chē)牌號(hào)double popstacktime;/專(zhuān)門(mén)存放出棧的時(shí)候返回的時(shí)刻;*【以下為類(lèi)的實(shí)現(xiàn)】*carstack:carstack()/構(gòu)造函數(shù),棧的初始化top=-1;s=new carM

22、ax;/創(chuàng)建car類(lèi)型棧元素的數(shù)組if(s=NULL)cout??臻g分配不成功!endl;exit(1);int carstack:full()/判斷棧是否為滿return top=Max-1;carqueue:carqueue()/構(gòu)造函數(shù),隊(duì)列的初始化rear=front=NULL;int parkingmanagement:pushstack(carstack &cs,int cnum,double ctime)/入棧,cs棧內(nèi)進(jìn)行調(diào)整,返回棧內(nèi)位置if(cs.top=Max-1)/Max從1開(kāi)始,top從0開(kāi)始cout停車(chē)場(chǎng)已滿!endl;return Max;else cs.top+

23、;(cs.scs.top).number=cnum;/將cnum賦給棧頂位置的車(chē)的車(chē)牌號(hào),s是car類(lèi)型棧元素的數(shù)組(cs.scs.top).time=ctime;/將ctime賦給棧頂位置的車(chē)的入棧時(shí)間,s是car類(lèi)型棧元素的數(shù)組return (cs.top+1);/返回棧內(nèi)位置加1,即停車(chē)場(chǎng)內(nèi)車(chē)位從1號(hào)開(kāi)始void parkingmanagement:popstack(carstack &cs,int cnum)/出棧,cs棧內(nèi)進(jìn)行調(diào)整,/根據(jù)車(chē)牌號(hào)把車(chē)彈出棧,將出棧car的number賦值給int popstacknumber/將出棧car的time賦值給double popstackt

24、ime,無(wú)返回值!int i;car p;carstack stemp;/定義一個(gè)carstack類(lèi)型的臨時(shí)存放出棧元素的棧for(i=0; ii)stemp.s+(stemp.top)=cs.s(cs.top)-;/出棧的元素?cái)?shù)組逐個(gè)賦給臨時(shí)棧popstacknumber=p.number;/將這個(gè)車(chē)牌號(hào)信息傳給int popstacknumber()popstacktime=p.time;/將該車(chē)的時(shí)間信息傳給double popstacktime()cs.top-;/棧頂指針回到原來(lái)位置while(stemp.top=0)cs.s+(cs.top)=stemp.s(stemp.top)-

25、;/臨時(shí)棧出棧的元素逐個(gè)賦給原棧,完成先退再進(jìn)的工作int parkingmanagement:pushqueue(carqueue &cq,int cnum,double ctime)/入隊(duì),隊(duì)內(nèi)進(jìn)行調(diào)整,返回隊(duì)內(nèi)位置car *p,*countp;int count(1);/count用于記錄車(chē)在過(guò)道上的位置信息,因隊(duì)列為鏈?zhǔn)降?,所以進(jìn)行循環(huán)累加p=new car;/創(chuàng)建一個(gè)car類(lèi)型的指針p-number=cnum;p-time=ctime;p-next=NULL;/首先將指向存放car類(lèi)型元素的數(shù)組初始地址置空if (cq.front=NULL)/第一次入隊(duì)要判斷頭結(jié)點(diǎn)是否為空cq.fr

26、ont=cq.rear=p;else /尾插法插入元素p-next=(cq.rear)-next;(cq.rear)-next=p;cq.rear=(cq.rear)-next;countp=(cq.front)-next;while(countp!=NULL)count+;countp=countp-next;/count即車(chē)在過(guò)道上的位置,【從1開(kāi)始計(jì)!】return count;int parkingmanagement:popqueue(carqueue &cq)/出隊(duì),隊(duì)內(nèi)進(jìn)行調(diào)整,返回汽車(chē)車(chē)牌號(hào)car p;p.number=(cq.front)-next)-number;/cq隊(duì)里

27、,從cq.front開(kāi)始指向下一個(gè)元素的車(chē)牌號(hào)賦給car類(lèi)型的車(chē)信息p.time=(cq.front)-next)-time;/cq隊(duì)里,從cq.front開(kāi)始指向下一個(gè)元素的時(shí)刻/賦給car類(lèi)型的車(chē)信息p.next=(cq.front)-next)-next;/cq隊(duì)里,從cq.front開(kāi)始指向下一個(gè)元素的指針/賦給car類(lèi)型的車(chē)信息的下一個(gè)元素的指針return p.number;cq.front=(cq.front)-next;void parkingmanagement:arrival(carstack &cs,carqueue &cq,int cnum,double ctime)/

28、車(chē)輛到達(dá),根據(jù)輸入的車(chē)牌號(hào)、到達(dá)時(shí)間,變更函數(shù)參數(shù);并cout車(chē)位信息int pos;if(!(cs.full()/如果棧未滿,車(chē)輛停入停車(chē)場(chǎng)int fl(0),i;/定義一個(gè)從0開(kāi)始的標(biāo)記flfor(i=0;i=cs.top;i+)if(cs.si.number=cnum)/如果到達(dá)的車(chē)的車(chē)牌號(hào)=棧內(nèi)已有車(chē)輛的車(chē)牌號(hào)fl=1;/fl記1break;if(fl=1)/如果到達(dá)的車(chē)的車(chē)牌號(hào)!=棧內(nèi)已有車(chē)輛的車(chē)牌號(hào)cout輸入錯(cuò)誤!請(qǐng)重新輸入!endl;elsepos=pushstack(cs,cnum,ctime);/入棧,返回車(chē)位信息cout該停車(chē)場(chǎng)還有空位,請(qǐng)到pos號(hào)車(chē)位進(jìn)行泊車(chē)endl;

29、coutendl;else/如果棧滿,車(chē)輛暫停便道pos=pushqueue(cq,cnum,ctime);/入隊(duì),返回車(chē)位信息cout該停車(chē)場(chǎng)已滿,請(qǐng)將車(chē)停到便道pos號(hào)車(chē)位上endl;coutendl;void parkingmanagement:leave(carstack &cs,carqueue &cq,int cnum,double ctime)/車(chē)輛離開(kāi),根據(jù)輸入的車(chē)牌號(hào)找到汽車(chē),并進(jìn)行出棧操作、出隊(duì)操作和入棧操作;并cout停留時(shí)間和收費(fèi)情況int i,flag(0),pstack,count(1),outcarnum;double hour;car *p;for(i=0;i=

30、cs.top;i+)if(cs.si).number=cnum)flag=1;break;if(flag)/如果輸入的車(chē)牌號(hào)與棧內(nèi)已有車(chē)輛的車(chē)牌號(hào)一致popstack(cs,cnum);/出棧操作hour=ctime-popstacktime;/時(shí)間計(jì)算outcarnum=popqueue(cq);/將便道上的第一輛車(chē)出隊(duì),入棧。并將其車(chē)牌號(hào)賦給outcarnumpstack=pushstack(cs,outcarnum,ctime);/將便道上的第一輛車(chē),入棧cout該車(chē)在本停車(chē)場(chǎng)內(nèi)停留時(shí)間為hour分鐘,應(yīng)付金額hour*(price/60)元!next;if(p-number=cnum)

31、/在過(guò)道中找到要出去的車(chē),則在隊(duì)列中刪除該car。/后面的車(chē)輛依然順序排列,補(bǔ)足空位deletequeue(cq,count);if(countMax)cout您的車(chē)在便道上的位置為count號(hào)車(chē)位,請(qǐng)自行駛離,無(wú)需付費(fèi)!endl;break;if(p=NULL)cout您的車(chē)不在本停車(chē)場(chǎng)內(nèi),或輸入有誤,請(qǐng)重新輸入!endl;void parkingmanagement:deletequeue(carqueue &cq,int i) car *p,*q;int j(0);p=cq.front;while(p & jnext;j+;/找到第i個(gè)節(jié)點(diǎn)(i從1開(kāi)始)if(!p | !p-next)c

32、outnext;p-next=q-next;delete q;*【以下是主程序】*void print()cout= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =endl;cout= 歡迎光臨! =endl;cout= =endl;cout= 本停車(chē)場(chǎng)收費(fèi)標(biāo)準(zhǔn)為:30元/小時(shí);車(chē)庫(kù)容量為:2 =endl;cout= =endl;cout= 請(qǐng)輸入您的泊車(chē)信息:格式為:(到達(dá)/離去/退出);車(chē)牌號(hào);現(xiàn)在時(shí)刻 =endl;cout= 其中,A:到達(dá);D:離去;E:退出系統(tǒng) =endl;cout= = = =

33、= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =acccarnumcartime;if(acc=A)park.arrival(cars,carq,carnum,cartime);else if(acc=D)park.leave(cars,carq,carnum,cartime);else if(acc=E)break;elsecout您的輸入有誤,請(qǐng)重新輸入!endl;#【3】【停車(chē)場(chǎng)管理系統(tǒng)【方案二 程序】#(ps:本方案與方案一有同樣的問(wèn)題,就是在對(duì) 便道上的車(chē) 進(jìn)行駛離操作時(shí),數(shù)據(jù)錯(cuò)誤,同樣的理由,沒(méi)有改正。如果有

34、細(xì)心娃娃幫忙指點(diǎn)改正,在此感激啦)*【以下為類(lèi)定義】*#include using namespace std;const int MaxSize=2;/停車(chē)場(chǎng)內(nèi)最多能停2輛車(chē)template class carStack;/template /定義模板類(lèi)struct Node/過(guò)道停車(chē)的隊(duì)列所需鏈?zhǔn)浇Y(jié)點(diǎn)T carnum;/定義車(chē)牌號(hào)類(lèi)型Node *next; /此處也可以省略;templateclass carinfo friend class carStack; public:T carnum; /車(chē)號(hào) int cartime;/停車(chē)時(shí)間;template class carQueuefr

35、iend class carStack;public:carQueue(); /構(gòu)造函數(shù),初始化一個(gè)空的鏈隊(duì)列int EnQueue(T cnum); /將元素x入隊(duì),并返回其在隊(duì)內(nèi)的位置(從1開(kāi)始)T DeQueue(); /將隊(duì)頭鏈?zhǔn)浇Y(jié)點(diǎn)出隊(duì),并返回汽車(chē)車(chē)牌號(hào)void deletequeue(int i);/將隊(duì)內(nèi)低i個(gè)元素刪除,即便道上i位置的汽車(chē)駛離bool Empty(); /判斷鏈隊(duì)列是否為空Node *front, *rear; ;templateclass carStackfriend class carinfo;public:carStack() ; /構(gòu)造函數(shù),棧的初始化,

36、停車(chē)場(chǎng)容量為【size】void Pushcar(T cnum,int ctime); /有車(chē)停入停車(chē)場(chǎng)int Popcar(T outcnum,int outctime); /將第cnum輛車(chē)出棧,并返回其停車(chē)時(shí)間(hour)bool full();/判斷棧是否為滿?滿則返回1carinfo *S;/?int top; ;*【以下為類(lèi)的實(shí)現(xiàn)】*template /初始化隊(duì)列carQueue:carQueue()front=rear=NULL;template int carQueue:EnQueue(T cnum)/車(chē)子進(jìn)入便道int i(0);Node *s,*p;/?s=new Node

37、;s-carnum=cnum;s-next=NULL;if(front=NULL)/空隊(duì)列,【新結(jié)點(diǎn)既是隊(duì)頭,又是隊(duì)尾】關(guān)鍵是!front指向第一個(gè)結(jié)點(diǎn) front=rear=s;else rear-next=s;/將結(jié)點(diǎn)s插入到隊(duì)尾rear=s;p=front;while(p!=NULL)i+;p=p-next;/i即車(chē)在過(guò)道上的位置,【從1開(kāi)始計(jì)!】return i;templateT carQueue:DeQueue()Node *p;if (front=NULL) coutnext;/將隊(duì)頭元素所在結(jié)點(diǎn)摘鏈return p-carnum;delete p;/將出隊(duì)進(jìn)棧的車(chē)從隊(duì)列里刪除t

38、emplatebool carQueue:Empty()/判斷是否為空,為空則返回1,不為空則返回0return front=NULL;template carStack:carStack()/構(gòu)造棧算法:top(-1)/建立一個(gè)最大尺寸為size的空棧S=new carinfoMaxSize;/創(chuàng)建存儲(chǔ)棧的數(shù)組if(S=NULL) /分配不成功 cerr動(dòng)態(tài)存儲(chǔ)失?。ndl;exit(1); /stdlib.htemplatevoid carStack:Pushcar(T cnum,int ctime)if (top=MaxSize-1)cout車(chē)場(chǎng)內(nèi)已停滿汽車(chē);elseS+top.car

39、num=cnum;Stop.cartime=ctime;templateint carStack:Popcar(T outcnum,int outctime)int i,hour;carStack Stemp;/建一個(gè)臨時(shí)模擬停車(chē)場(chǎng)int Stop=-1;for(i=0;ii)Stemp.S+Stop=Stop-;hour=outctime-Stop.cartime;return hour;top-;while(Stop=0)S+top=Stemp.SStop-;templatebool carStack:full()return top=MaxSize-1;template void car

40、Queue:deletequeue(int i)Node *p,*q;int j(1);p=front;while(p & jnext;j+;/找到第i-1個(gè)結(jié)點(diǎn)(結(jié)點(diǎn)位置從1開(kāi)始)if(!p|!p-next)couti不合法!next;p-next=q-next;delete q;*【以下為主函數(shù)】*void outputpark()/系統(tǒng)功能選擇頁(yè)面,輸入泊車(chē)信息cout=endl;cout 歡迎來(lái)到秦小寶停車(chē)場(chǎng)!endl;cout (本停車(chē)場(chǎng)收費(fèi)標(biāo)準(zhǔn)為5元/小時(shí),60分鐘以內(nèi)記為1小時(shí))endl;cout=endl;cout請(qǐng)輸入您的車(chē)輛信息:endl;cout(泊車(chē)輸入A/駛離輸入D/

41、退出系統(tǒng)輸入E;請(qǐng)輸入您的車(chē)牌號(hào);請(qǐng)輸入現(xiàn)在時(shí)刻)endl;void main()int carnum,cartime;char arrive;carStack cs;carQueue cq;while(1)outputpark();cinarrivecarnumcartime;if(arrive=A)if(cs.top!=MaxSize-1)/停車(chē)場(chǎng)內(nèi)有空位可以駛?cè)隿s.Pushcar(carnum,cartime);cout請(qǐng)駛?cè)胪\?chē)場(chǎng)的cs.top+1號(hào)車(chē)位endl;elsecout請(qǐng)駛?cè)氡愕赖腸q.EnQueue(carnum)號(hào)車(chē)位endl;/將車(chē)輛進(jìn)行入隊(duì)操作,即停入便道else

42、if(arrive=D)int flag(0),i;for(i=0;i=cs.top;i+)if(cs.Si.carnum=carnum)flag=1;break;if(flag)int hour;hour=cs.Popcar(carnum,cartime);cout您的carnum車(chē)在秦小寶停車(chē)場(chǎng)內(nèi)停留時(shí)間為:hourendl;cout需要繳納的費(fèi)用為:hour*5元!endl;cs.Pushcar(cq.DeQueue(),cartime);/出隊(duì)一輛車(chē),并將該車(chē)進(jìn)行入棧處理elseint flagde(0),pos(0);/若該車(chē)在便道內(nèi),pos用來(lái)記錄該車(chē)便道內(nèi)的位置Node *p;p

43、=cq.front;while(p!=NULL)if(p-carnum=carnum)flagde=1;break;pos+;p=p-next;if(flagde)cout您的車(chē)停在便道上pos號(hào)車(chē)位,無(wú)需繳納費(fèi)用,請(qǐng)自行駛離!endl;cq.deletequeue(pos);elsecout輸入有誤,或您的車(chē)不在秦小寶停車(chē)場(chǎng)內(nèi)!請(qǐng)重新輸入endl;else if(arrive=E)break; elsecout您的輸入有誤,請(qǐng)重新輸入!endl; (ps:本方案截圖與方案一截圖差不多,所以就不做了)(英文版 ) easily blame, to prevent the broken wind

44、ow effect. Supervise the leading cadres to play an exemplary role, take the lead in the strict implementation of the and , lead to safeguard the solemnity and authority of the party discipline, ensure that the party discipline and the laws and regulations for implementation in place. Throughout the

45、discipline in the daily supervision and management, strengthen supervision and inspection, from the thorough investigation of violations of discipline behavior. Strengthen to key areas, key departments and key projects as well as the masses reflect the concentration of the units and departments for

46、supervision. - strengthening supervision, discipline inspection and supervision of cadres to set an example for compliance with the and is a man must be hexyl, blacksmith needs its own hardware. Discipline inspection organs as the executor of the party discipline, and supervisor of the defenders, fo

47、r its supervision must be more strictly, discipline inspection and supervision of cadres to firmly establish the awareness of Party Constitution, sense of discipline and rules consciousness, politics loyalty, sense obey. Action speak Ji Ordinance to set an example of the regulations of the rule of l

48、aw, strengthen supervision and accept the supervision of the firmness and consciousness, do comply with and . To firmly establish the discipline must first be disciplined, the supervisor will be subject to the supervision of concept, and consciously safeguard and implement party compasses party, tak

49、e the lead in practicing three strict real strict, so loyal, clean, play. To be good at learning, the Constitution and the as morality, politics and brought to fruition; to implement , do not want to, dare not, not with disciplinary ruler to supervision; to discipline a ruler, often the control inspection, an

展開(kāi)閱讀全文
溫馨提示:
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. 裝配圖網(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ì)自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!