Pagini recente » Cod sursa (job #2435840) | Profil UNIBUC_Barbalau_Bucur_Matei | Cod sursa (job #2150930) | Cod sursa (job #168300)
Cod sursa(job #168300)
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
int main(void){
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
int n,j,i,k;
fin >> n;
int x[n][n];
for (i=0;i<n;i++)
for (j=0;j<n;j++)
fin >> x[i][j];
for (k=0;k<n;k++)
for (i=0;i<n;i++)
for (j=0;j<n;j++)
if (x[i][k] + x[k][j] < x[i][j])
x[i][j] = x[i][k] + x[k][j];
for (i=0;i<n;i++){
for (j=0;j<n;j++)
fout << x[i][j] << " ";
fout << "\n";
}
fin.close();
fout.close();
return 0;
}