Create floyd.cpp

This commit is contained in:
KiritoTRw 2016-08-11 09:06:44 +08:00 committed by GitHub
parent 2ad9f25785
commit 0d0d02cf94

18
.ACM-Templates/floyd.cpp Normal file
View File

@ -0,0 +1,18 @@
for(int k=1;k<=n;k++)
{
for(int f=1;f<=n;f++)
{
for(int t=1;t<=n;t++)
{
if(f==t||f==k||t==k) continue;
if(m[f][k]!=INF&&m[k][t]!=INF)
{
int total=m[f][k]+m[k][t];
if(total<m[f][t]||m[f][t]==INF)
{
m[f][t]=total;
}
}
}
}
}