?? floydp.cpp
字號:
//FloydP.cpp
#include<iostream.h>
#include<iomanip.h>
#include "graph0.cpp"
#include "FloydP.h"
//弗洛伊德算法測試
void main()
{cout<<"FloydP.cpp運行結(jié)果:\n";
int i,j,e=9,n=6,k2=1;
RCW rcw[9]={{0,2,5},{0,3,30},{1,0,2},{1,4,8},
{2,1,15},{2,5,7},{4,3,4},{5,3,10},{5,4,18}};
AdjMatrix g(n,k2);
g.CreateMatrix(n,1,k2,rcw);
g.Creatgraph(n,e,rcw);
int dist[6][6];
int path[6][6];
Floyd(g,dist,path);
for(i=0;i<n;i++)
{cout<<"從頂點"<<g.GetValue(i)
<<"到其他各頂點的最短距離為:\n";
for(j=0;j<n;j++)
cout<<"到頂點"<<g.GetValue(j)
<<"的最短距離為:"<<dist[i][j]<<endl;
cout<<"從頂點"<<g.GetValue(i)
<<"到其他各頂點的最短路徑的前一頂點為:\n";
for(j=0;j<n;j++)
if(path[i][j]!=-1)
cout<<"到頂點"<<g.GetValue(j)<<"的前一頂點為:"
<<g.GetValue(path[i][j])<<endl;
}
cin.get();cin.get();}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -