Pagini recente » Cod sursa (job #2574027) | Cod sursa (job #2543632) | Cod sursa (job #2516702) | Cod sursa (job #3135321) | Cod sursa (job #3189730)
#include <iostream>
#include <fstream>
#define nl '\n'
using namespace std;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
const int NMAX = 101;
int n, c[NMAX][NMAX];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
fin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
fin >> c[i][j];
for (int k = 1; k <= n; k++)
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
fout << c[i][j] << ' ';
fout << nl;
}
return 0;
}