網(wǎng)站首頁 編程語言 正文
本文實例為大家分享了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
相關(guān)推薦
- 2022-08-21 golang類型推斷與隱式類型轉(zhuǎn)換_Golang
- 2023-04-26 Flask接口簽名sign原理與實例代碼淺析_python
- 2022-04-04 react Ant Design使用a標(biāo)簽href屬性警告解決方法
- 2022-05-15 Python數(shù)據(jù)結(jié)構(gòu)與算法中的棧詳解_python
- 2022-08-18 詳解Flutter中數(shù)據(jù)傳遞的方式_Android
- 2023-07-05 【nacos優(yōu)化】定時刪除access日志
- 2022-09-30 Spi機(jī)制在Android開發(fā)的應(yīng)用示例詳解_Android
- 2023-04-06 C語言中雙鏈表的基本操作_C 語言
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支