mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create floyd.cpp
This commit is contained in:
parent
2ad9f25785
commit
0d0d02cf94
18
.ACM-Templates/floyd.cpp
Normal file
18
.ACM-Templates/floyd.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user