Pagini recente » Monitorul de evaluare | Cod sursa (job #3359024) | Cod sursa (job #3360763) | Monitorul de evaluare | Cod sursa (job #3360231)
#include <bits/stdc++.h>
using namespace std;
ifstream f("royfloyd.in");
ofstream g("royfloyd.out");
const int nmax = 100;
int dist[nmax][nmax];
int main() {
int n; f >> n;
for(int i = 0, j; i < n; i ++)
for(j = 0; j < n; j ++)
f >> dist[i][j];
for(int i, j, k = 0; k < n; k ++)
for(i = 0; i < n; i ++)
for(j = 0; j < n; j ++)
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
for(int i = 0, j; i < n; i ++)
for(j = 0; j < n; j ++)
g << dist[i][j] << " \n"[j == n - 1];
}