日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

C++基于Floyd算法實現(xiàn)校園導(dǎo)航系統(tǒng)_C 語言

作者:很小小的 ? 更新時間: 2022-05-24 編程語言

本文實例為大家分享了C++基于Floyd算法實現(xiàn)校園導(dǎo)航系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

首先是配置文件

//文件名'MGraph.h'
//用途:創(chuàng)建鄰接矩陣
#include
#include
using namespace std;
/*
*author:xcy?
*date:2019.6.1?
*/
#define MaxInt 32767 //表示極大值
#define MaxNum 100 ?//表示最大頂點數(shù)
typedef int status;
typedef string VerTexType; ?//頂點的數(shù)據(jù)類型
typedef int ArcType; ?//邊的權(quán)值為整型
typedef struct
{
? ? VerTexType vexs[MaxNum]; ? //頂點表
? ? ArcType arcs[MaxNum][MaxNum]; ? //鄰接矩陣
? ? int vexnum,arcnum;//當(dāng)前的點和邊數(shù)
? ? char name[MaxNum];
}AMGraph;

status CreateMap(AMGraph &G)//地圖的創(chuàng)建?
{
? ? G.vexnum=10;?
? ? G.arcnum=13;
? ? G.vexs[0]="北門";
? ? G.vexs[1]="下沉廣場";
? ? G.vexs[2]="青年公寓";
? ? G.vexs[3]="齊賢廣場";
? ? G.vexs[4]="15教";
? ? G.vexs[5]="菜鳥驛站";
? ? G.vexs[6]="匯森樓";
? ? G.vexs[7]="圖書館";
? ? G.vexs[8]="體育館";
? ? G.vexs[9]="南苑餐廳";
? ??
? ? for(int i=0;i

具體方法實現(xiàn)

#include
#include
#include"MGraph.h"?
using namespace std;
/*
*author:xcy?
*date:2019.6.12
*change:使用弗洛依德算法?
*/

int shortPath[MaxNum][MaxNum];//最短路徑長度?
int Path[MaxNum][MaxNum];//保存下一個節(jié)點?
void ShortestPath_Floyd(AMGraph G)//弗洛依德算法
{
? ? int i,j,k;
? ? for(i=0;i>a;
? ? cout<<"輸入終點的序號"<>b;
? ? m=a-1;
? ? n=b-1;
? ? cout<<"最短路徑:"< "< "<>a;
? ? ?? ?(int)a;
? ? ?? ?if(a>'0'&&a<='3')
?? ??? ??? ?switch(a)
?? ? ? ??? ?{
?? ? ? ? ??? ??? ?case '1': scence(); break;
?? ? ? ? ??? ??? ?case '2': math(); break;
?? ? ? ? ??? ??? ?case '3': cout<<"\t\t\t感謝您的使用!";exit(0);break;
?? ? ??? ??? ?}
? ?? ??? ?else cout<<"\t\t\t請輸入1-3!!"<

原文鏈接:https://blog.csdn.net/weixin_44371591/article/details/92001056

欄目分類
最近更新