Pagini recente » Cod sursa (job #2129435) | Cod sursa (job #427657) | Cod sursa (job #2708960) | Cod sursa (job #408665) | Cod sursa (job #3283435)
#include <bits/stdc++.h>
#define oo 1000000007
using namespace std;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
int n, d[105][105];
int main()
{
ios_base::sync_with_stdio(0);
fin.tie(0);
fout.tie(0);
int i,j,k;
fin >> n;
for(i = 1; i <= n; i++)
for(j = 1; j <= n; j++)
fin >> d[i][j];
for(k = 1; k <= n; k++)
for(i = 1; i <= n; i++)
for(j = 1; j <= n; j++)
if(d[i][j] > d[i][k] + d[k][j])
d[i][j] = d[i][k] + d[k][j];
for(i = 1; i <= n; i++, fout << "\n")
for(j = 1; j <= n; j++)
fout << d[i][j] << " ";
return 0;
}