Pagini recente » Cod sursa (job #2153321) | Cod sursa (job #255845) | Cod sursa (job #2277355) | Cod sursa (job #1613944) | Cod sursa (job #2964869)
#include <fstream>
using namespace std;
ifstream fin ("royfloyd.in");
ofstream fout("royfloyd.out");
int n,c[101][101];
void rw()
{
for(int z=0;z<n;z++)
{
for(int x=0;x<n;x++)
for(int y=0;y<n;y++)
c[x][y] = min(c[x][y],c[x][z]+c[z][y]);
}
}
void citire()
{
fin>>n;
for(int i=0;i<n;i++) for(int j=0;j<n;j++)
fin>>c[i][j];
}
void afisare()
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
fout<<c[i][j]<<' ';
fout<<'\n';
}
}
int main()
{
citire();
rw();
afisare();
return 0;
}