Pagini recente » Cod sursa (job #1914637) | Cod sursa (job #1382049) | Cod sursa (job #2449288) | Cod sursa (job #32149) | Cod sursa (job #3257797)
/******************************************************************************
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 <iostream>
int mat[105][105];
using namespace std;
int main()
{
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;
}