版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
DONGFANGCOLLEGE,F(xiàn)UJIANAGRICULTUREANDFORESTRYUNIVERSITYC++程序設(shè)計課程設(shè)計報告課程設(shè)計:校園導(dǎo)游系統(tǒng)系別:計算機(jī)系年級:10級專業(yè):計算機(jī)科學(xué)與技術(shù)班級:1班學(xué)號:姓名:成績:任課教師:年8月20日目錄1.需求分析…………………32.概要設(shè)計.............................………………33.具體設(shè)計………………….34.使用闡明………………….35.測試成果……………….…46.附錄………57.參照文獻(xiàn)…………………14
需求分析設(shè)計一種校園導(dǎo)游程序,為來訪旳客人提供多種信息查詢服務(wù)。概要設(shè)計(1)設(shè)計你所在學(xué)校旳校園平面圖,所含景點(diǎn)不少于10個。以圖中頂點(diǎn)表達(dá)校內(nèi)各景點(diǎn),寄存景點(diǎn)名稱、代號、簡介等信息;以邊表達(dá)途徑,寄存途徑長度等有關(guān)信息。(2)為來訪客人提供圖中任意景點(diǎn)有關(guān)信息旳查詢。(3)為來訪客人提供圖中任意景點(diǎn)旳問路查詢,即查詢?nèi)我鈨蓚€景點(diǎn)之間旳一條最短旳簡樸途徑。具體設(shè)計以輸出流顯示校園旳界面以圖旳形式存儲校園景點(diǎn)以循環(huán)算法運(yùn)營操作界面以函數(shù)調(diào)用實(shí)現(xiàn)導(dǎo)游功能界面顯示函數(shù)界面顯示函數(shù)圖旳存儲主函數(shù)實(shí)現(xiàn)功能使用闡明運(yùn)營時顯示校園景觀圖,同步顯示選擇菜單選擇菜單:1.地點(diǎn)簡介2.最短途徑3.結(jié)束“請選擇功能”地點(diǎn)簡介:浮現(xiàn)景點(diǎn)選擇:A.操場B.偏門C.圖書館D.大門E.食堂F.誠智樓G.博學(xué)樓H.創(chuàng)新樓I.海天樓J.明德樓請選擇地點(diǎn)(選擇加回車即能查詢景點(diǎn)信息)最短途徑:浮現(xiàn)“輸入起點(diǎn)位置”,輸入后即浮現(xiàn)“輸入終點(diǎn)位置”(輸入加回車即顯示兩景點(diǎn)旳最短途徑)測試成果運(yùn)營界面地點(diǎn)簡介最短途徑附錄校園景觀圖實(shí)現(xiàn)函數(shù):voidviewshow(){ cout<<"東方學(xué)院實(shí)景圖"<<endl; cout<<""<<endl; cout<<"A操場-----B偏門"<<endl; cout<<"/\\"<<endl; cout<<"/\\"<<endl; cout<<"C圖書館------D大門E食堂----------\\"<<endl; cout<<"/\\\\"<<endl; cout<<"/\\F誠智樓---G博學(xué)樓-H創(chuàng)新樓"<<endl; cout<<"/\\ /"<<endl; cout<<"I海天樓--------J明德樓"<<endl; cout<<""<<endl;}建立圖函數(shù):#include"SeqList.h"#include"SeqQueue.h"constintMaxVertices=10;constintMaxWeight=10000;classAdjMWGraph{private: SeqListVertices;//頂點(diǎn)信息旳線性表 intEdge[MaxVertices][MaxVertices]; intnumOfEdges;public: AdjMWGraph(constintsz=MaxVertices); intGraphEmpty()const {returnVertices.ListEmpty();} intNumOfVertices(void) {returnVertices.ListSize();} intNumOfEdges(void) {returnnumOfEdges;} VerTGetValue(constinti); intGetWeight(constintv1,constintv2); voidInsertVertex(constVerT&vertex); voidInsertEdge(constintv1,constintv2,intweight); voidDeleteVertex(constinti); voidDeleteEdge(constintv1,constintv2); intGetFirstNeighbor(constintv); intGetNextNeighbor(constintv1,constintv2); voidDepthFirstSearch(constintv,intvisited[],voidvisit(VerTitem)); voidBroadFirstSearch(constintv,intvisited[],voidvisit(VerTitem)); voidDepthFirstSearch(voidvisit(VerTitem)); voidBroadFirstSearch(voidvisit(VerTitem));};AdjMWGraph::AdjMWGraph(constintsz){ for(inti=0;i<sz;i++) for(intj=0;j<sz;j++) { if(i==j)Edge[i][j]=0; elseEdge[i][j]=MaxWeight; } numOfEdges=0;}VerTAdjMWGraph::GetValue(constinti){ if(i<0||i>Vertices.ListSize()) { cerr<<"參數(shù)i越界出錯!"<<endl; exit(1); } returnVertices.GetData(i);}intAdjMWGraph::GetWeight(constintv1,constintv2){ if(v1<0||v1>Vertices.ListSize()||v2<0||v2>Vertices.ListSize()) { cerr<<"參數(shù)v1或v2越界出錯!"<<endl; exit(1); } returnEdge[v1][v2];}voidAdjMWGraph::InsertVertex(constVerT&vertex){ Vertices.Insert(vertex,Vertices.ListSize());}voidAdjMWGraph::InsertEdge(constintv1,constintv2,intweight){ if(v1<0||v1>Vertices.ListSize()||v2<0||v2>Vertices.ListSize()) { cerr<<"參數(shù)v1或v2越界出錯!"<<endl; exit(1); } Edge[v1][v2]=weight; numOfEdges++;}voidAdjMWGraph::DeleteVertex(constintv){ for(inti=0;i<Vertices.ListSize();i++) for(intj=0;j<Vertices.ListSize();j++) if((i==v||j==v)&&Edge[i][j]>0&&Edge[i][j]<MaxWeight) { Edge[i][j]=MaxWeight; numOfEdges--; } Vertices.Delete(v);}voidAdjMWGraph::DeleteEdge(constintv1,constintv2){ if(v1<0||v1>Vertices.ListSize()||v2<0||v2>Vertices.ListSize()||v1==v2) { cerr<<"參數(shù)v1或v2出錯!"<<endl; exit(1); } Edge[v1][v2]=MaxWeight; numOfEdges--;}intAdjMWGraph::GetFirstNeighbor(constintv){ if(v<0||v>Vertices.ListSize()) { cerr<<"參數(shù)v1越界出錯!"<<endl; exit(1); } for(intcol=0;col<=Vertices.ListSize();col++) if(Edge[v][col]>0&&Edge[v][col]<MaxWeight)returncol; return-1;}intAdjMWGraph::GetNextNeighbor(constintv1,constintv2){ if(v1<0||v1>Vertices.ListSize()||v2<0||v2>Vertices.ListSize()) { cerr<<"參數(shù)v1或v2越界出錯!"<<endl; exit(1); } for(intcol=v2+1;col<=Vertices.ListSize();col++) if(Edge[v1][col]>0&&Edge[v1][col]<MaxWeight)returncol; return-1;}voidAdjMWGraph::DepthFirstSearch(constintv,intvisited[],voidvisit(VerTitem)){ visit(GetValue(v)); visited[v]=1; intw=GetFirstNeighbor(v); while(w!=-1) { if(!visited[w])DepthFirstSearch(w,visited,visit); w=GetNextNeighbor(v,w); }}voidAdjMWGraph::BroadFirstSearch(constintv,intvisited[],voidvisit(VerTitem)){ VerTu,w; SeqQueuequeue;//定義隊列queue visit(GetValue(v)); visited[v]=1; queue.QInsert(v); while(!queue.QueueEmpty()) { u=queue.QDelete(); w=GetFirstNeighbor(u); while(w!=-1) { if(!visited[w]) { visit(GetValue(w)); visited[w]=1; queue.QInsert(w); } w=GetNextNeighbor(u,w); } }}voidAdjMWGraph::DepthFirstSearch(voidvisit(VerTitem)){ int*visited=newint[NumOfVertices()]; for(inti=0;i<NumOfVertices();i++)visited[i]=0; for(i=0;i<NumOfVertices();i++) if(!visited[i])DepthFirstSearch(i,visited,visit); delete[]visited;}//非連通圖旳廣度優(yōu)先搜索遍歷算法如下voidAdjMWGraph::BroadFirstSearch(voidvisit(VerTitem)){ int*visited=newint[NumOfVertices()]; for(inti=0;i<NumOfVertices();i++)visited[i]=0; for(i=0;i<NumOfVertices();i++) if(!visited[i])BroadFirstSearch(i,visited,visit); delete[]visited;}structRowColWeight{ introw; intcol; intweight;};voidCreatGraph(AdjMWGraph&G,DatatypeV[],intn,RowColWeightE[],inte)//建圖{ for(inti=0;i<n;i++)G.InsertVertex(V[i]); for(intk=0;k<e;k++)G.InsertEdge(E[k].row,E[k].col,E[k].weight);}voidPrintchar(charitem){ cout<<item<<"";}voidDijkstra(AdjMWGraph&G,intv0,intdistance[],intpath[]){ intn=G.NumOfVertices(); int*s=newint[n]; intminDis,i,j,u; for(i=0;i<n;i++) { distance[i]=G.GetWeight(v0,i); s[i]=0; if(i!=v0&&distance[i]<MaxWeight)path[i]=v0; elsepath[i]=-1; } s[v0]=1; for(i=1;i<n;i++) { minDis=MaxWeight; for(j=0;j<=n;j++) if(s[j]==0&&distance[j]<minDis) { u=j; minDis=distance[j]; } if(minDis==MaxWeight)return; s[u]=1; for(j=0;j<n;j++) if(s[j]==0&&G.GetWeight(u,j)<MaxWeight&&distance[u]+G.GetWeight(u,j)<distance[j]) { distance[j]=distance[u]+G.GetWeight(u,j); path[j]=u; } }}主函數(shù):typedefcharVerT;typedefcharDatatype;#include"AdjMWGraph.h"#include"View.h"intmain(){ ints,sss=1,j=1; charch,qd,zd; AdjMWGraphg; chara[]={'A','B','C','D','E','F','G','H','I','J'}; RowColWeightrcw[]={{0,1,20},{0,3,30},{0,4,30},{1,0,20},{2,3,20},{3,0,30},{3,2,20},{3,8,30},{3,9,20},{4,0,30},{4,6,20},{5,6,15},{5,9,15},{6,4,20},{6,5,15},{6,7,10},{7,6,10},{8,3,30},{8,9,15},{9,5,15},{9,8,15}}; intn=10,e=24; CreatGraph(g,a,n,rcw,e); intm=g.NumOfVertices(); int*distance=newint[m]; int*path=newint[m]; intv0=0,v1; Dijkstra(g,v0,distance,path);end: if(j==0){system("cls");} do{ viewshow(); cout<<"1.地點(diǎn)簡介2.最短途徑3.結(jié)束"<<endl<<"請選擇功能:"; cin>>s; system("cls"); if(s==1) { do{ viewshow(); cout<<"A.操場B.偏門C.圖書館D.大門E.食堂"<<endl <<"F.誠智樓G.博學(xué)樓H.創(chuàng)新樓I.海天樓J.明德樓"<<endl<<"請選擇地點(diǎn):"; cin>>ch;switch(ch) { case'A': zhengdamenshow(); cin.get(); cin.get(); system("cls");break; case'B': mdshow(); cin.get(); cin.get(); system("cls");break; case'C': czshow(); cin.get(); cin.get(); system("cls");break; case'D': bxshow(); cin.get(); cin.get(); system("cls");break; case'E': cxshow(); cin.get(); cin.get(); system("cls");break; case'F': bahaoshow(); cin.get(); cin.get(); system("cls");break; case'G': sitangshow(); cin.get(); cin.get(); system("cls");break; case'H': shihaoshow(); cin.get(); cin.get(); system("cls");break; case'I': caochangshow(); cin.get(); cin.get(); system("cls");break; case'J': tushuguanshow(); cin.get(); cin.get(); system("cls");break; case'K': j=0; gotoend; default: cout<<"選擇有誤,請重新選擇!"<<endl; cin.get(); cin.get(); system("cls"); } }while(1); }if(s==2) { do{ viewshow();QIDIAN: cout<<"請輸入起點(diǎn)位置:"; cin>>qd; if(qd=='A')v0=0; elseif(qd=='B')v0=1; elseif(qd=='C')v0=2; elseif(qd=='D')v0=3; elseif(qd=='E')v0=4; elseif(qd=='F')v0=5; elseif(qd=='G')v0=6; elseif(qd=='H')v0=7; elseif(qd=='I')v0=8;
溫馨提示
- 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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 20263D模型師招聘試題及答案
- 中化學(xué)華誼工程科技集團(tuán)有限公司2026屆校園招聘參考題庫必考題
- 南昌職教城教育投資發(fā)展有限公司2025年第七批公開招聘工作人員專題參考題庫附答案
- 國家電投集團(tuán)蘇州審計中心選聘參考題庫附答案
- 岳池縣關(guān)于2025年社會化選聘新興領(lǐng)域黨建工作專員的考試備考題庫必考題
- 招2人!2025年同德縣文化館面向社會公開招聘政府聘用人員的考試備考題庫必考題
- 江西省供銷合作社聯(lián)合社公開招聘江西省金合控股集團(tuán)有限公司副總經(jīng)理及財務(wù)總監(jiān)專題備考題庫必考題
- 石棉縣人力資源和社會保障局關(guān)于2025年下半年面向縣內(nèi)公開考調(diào)事業(yè)單位工作人員的(7人)參考題庫必考題
- 遼寧科技大學(xué)2026年招聘高層次和急需緊缺人才102人備考題庫必考題
- 雅安市衛(wèi)生健康委員會所屬事業(yè)單位雅安市衛(wèi)生健康與人才服務(wù)中心2025年公開選調(diào)事業(yè)人員的參考題庫必考題
- 學(xué)生計算錯誤原因分析及對策
- DB32T 4398-2022《建筑物掏土糾偏技術(shù)標(biāo)準(zhǔn)》
- (精確版)消防工程施工進(jìn)度表
- 保險公司資產(chǎn)負(fù)債表、利潤表、現(xiàn)金流量表和所有者權(quán)益變動表格式
- 送貨單格式模板
- 防止激情違紀(jì)和犯罪授課講義
- XX少兒棋院加盟協(xié)議
- 五年級數(shù)學(xué)應(yīng)用題專題訓(xùn)練50題
- 2021年四川省資陽市中考數(shù)學(xué)試卷
- 河南省鄭氏中原纖維素有限公司年產(chǎn) 0.2 萬噸預(yù)糊化淀粉、0.5 萬噸羧甲基纖維素鈉、1.3 萬噸羧甲基淀粉鈉項(xiàng)目環(huán)境影響報告
- 高處作業(yè)安全培訓(xùn)課件
評論
0/150
提交評論