Pagini recente » Cod sursa (job #1228037) | Cod sursa (job #2924425) | Cod sursa (job #2805240) | Cod sursa (job #92850) | Cod sursa (job #2448022)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("royfloyd.in");
ofstream fout ("royfloyd.out");
int a[105][105];
int main()
{
ios::sync_with_stdio(false);
fin.tie(0);
int n;
fin >> n;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
cin >> a[i][j];
for(int k = 1; k <= n; ++k) {
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j) {
a[i][j] = min(a[i][k] + a[k][j], a[i][j]);
}
}
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j)
fout << a[i][j] << " ";
fout << "\n";
}
return 0;
}