Pagini recente » Cod sursa (job #1980750) | Cod sursa (job #1980763) | Cod sursa (job #3146304) | Cod sursa (job #2543904) | Cod sursa (job #3278442)
#include <fstream>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
ifstream cin("royfloyd.in");
ofstream cout("royfloyd.out");
int v[105][105];
int n;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
for(int k=1;k<=n;k++)
{
cin>>v[i][k];
}
}
for(int i=1;i<=n;i++)
{
for(int k=1;k<=n;k++)
{
for(int j=1;j<=n;j++)
{
v[i][k]=min(v[i][k], v[i][j]+v[j][k] );
}
}
}
for(int i=1;i<=n;i++)
{
for(int k=1;k<=n;k++)
{
cout<<v[i][k]<<" ";
}
cout<<'\n';
}
return 0;
}
//manuscrisul voinici