Pagini recente » Cod sursa (job #76128) | Cod sursa (job #973203) | Cod sursa (job #2230609) | Cod sursa (job #2196293) | Cod sursa (job #3237349)
#include<fstream>
using namespace std;
ifstream F("royfloyd.in");
ofstream G("royfloyd.out");
int n,i,j,k,a[100][100];
int main()
{
for(F>>n;i<n;++i)
for(j=0;j<n;F>>a[i][j++]);
for(;k<n;++k)
for(i=0;i<n;++i)
for(j=0;j<n;++j)
if(i!=j&&a[i][k]&&a[k][j]&&(!a[i][j]||a[i][j]>a[i][k]+a[k][j]))
a[i][j]=a[i][k]+a[k][j];
for(i=0;i<n;G<<'\n',++i)
for(j=0;j<n;G<<a[i][j++]<<' ');
return 0;
}