Cod sursa(job #2340423)
| Utilizator | Data | 10 februarie 2019 14:03:32 | |
|---|---|---|---|
| Problema | Floyd-Warshall/Roy-Floyd | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.6 kb |
#include <fstream>
using namespace std;
ifstream cin ("royfloyd.in");
ofstream cout ("royfloyd.out");
int n, mat[105][105];
int main()
{
cin >> n;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
cin >> mat[i][j];
for(int k = 1; k <= n; ++k)
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= n; ++j)
cout << mat[i][j] << ' ';
cout << '\n';
}
return 0;
}
