Pagini recente » Cod sursa (job #2260290) | Cod sursa (job #3176392) | Cod sursa (job #2987686) | Cod sursa (job #2266235) | Cod sursa (job #3257803)
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
#define int long long
int mat[105][105];
using namespace std;
signed main()
{
ifstream cin("royfloyd.in");
ofstream cout("royfloyd.out");
int n;
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cin>>mat[i][j];
}
}
for(int k=0;k<n;k++)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(mat[i][j]&&mat[i][k]&&mat[j][k])
{
mat[i][j]=min(mat[i][j],mat[i][k]+mat[k][j]);
}
}
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cout<<mat[i][j]<<" ";
}
cout<<'\n';
}
return 0;
}