package com.jkxy.photoDeep;
public class warshall {
static int k,i,j;
static int e[][]={{0,0,0,0,0},
{0,0,2,6,4},
{0,9999,0,3,9999},
{0,7,9999,0,1},
{0,5,9999,12,0}};
public static void main(String[] args) {
for(k=1;k<=4;k++)
for(i=1;i<=4;i++)
for(j=1;j<=4;j++){
if(e[i][j]>e[i][k]+e[k][j]){
e[i][j]=e[i][k]+e[k][j];
}
}
for(i=1;i<=4;i++){
for(j=1;j<=4;j++){
System.out.print(e[i][j]+"/");
}
}
}
}
/*多源最短路径:五行代码*/
蓝桥-最短路径1-warshall
最新推荐文章于 2023-08-17 18:11:22 发布