Pagini recente » Cod sursa (job #2109211) | Cod sursa (job #664422) | Cod sursa (job #2882517) | Cod sursa (job #2756807) | Cod sursa (job #3211973)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
const int NMAX = 100;
int n, d[101][101];
int main(){
fin >> n;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
fin >> d[i][j];
for(int k = 1; k <= n; k++)
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
for(int i = 1; i <= n; i++, fout << '\n')
for(int j = 1; j <= n; j++)
fout << d[i][j] << ' ';
return 0;
}