Cod sursa(job #2343512)
| Utilizator | Data | 14 februarie 2019 08:14:19 | |
|---|---|---|---|
| Problema | Floyd-Warshall/Roy-Floyd | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.65 kb |
#include <fstream>
using namespace std;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
int m[105][105];
int n;
void citire();
int main()
{
int i,j,k;
citire();
for(k=1;k<=n;k++)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
m[i][j]=min(m[i][j],m[i][k]+m[k][j]);
}
}
}
for(i=1;i<=n;i++)
{for(j=1;j<=n;j++)
{
fout<<m[i][j]<<' ';
}
fout<<'\n';
}
return 0;
}
void citire()
{
int i,j;
fin>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
fin>>m[i][j];
}
}
