Pagini recente » Cod sursa (job #2284399) | Cod sursa (job #2599393) | Cod sursa (job #935308) | Cod sursa (job #650714) | Cod sursa (job #2575127)
#include <bits/stdc++.h>
using namespace std;
int n;
int matrice[105][105];
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
int main()
{
fin>>n;
for(int i =0;i<n;i++)
{
for(int j = 0;j<n;j++)
{
fin>>matrice[i][j];
if(matrice[i][j]==0 && i!=j)
{
matrice[i][j]=234132434;
}
}
}
for(int k = 0;k<n;k++)
{
for(int i = 0;i<n;i++)
{
for(int j = 0;j<n;j++)
{
matrice[i][j] = min(matrice[i][j],
matrice[i][k]+matrice[k][j]);
}
}
}
for(int i = 0;i<n;i++)
{
for(int j = 0;j<n;j++)
{
fout<<matrice[i][j]<<" ";
}
fout<<'\n';
}
return 0;
}