Pagini recente » Cod sursa (job #2086229) | Cod sursa (job #2600307) | Cod sursa (job #2813830) | Cod sursa (job #672563) | Cod sursa (job #2878265)
#include <iostream>
#include <fstream>
using namespace std;
const string filename = "royfloyd";
ifstream fin(filename + ".in");
ofstream fout(filename + ".out");
int n;
int dist[105][105];
int main()
{
fin >> n;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
fin >> dist[i][j];
for(int k = 1; k <= n; k++)
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
fout << dist[i][j] << ' ';
fout << '\n';
}
return 0;
}