Pagini recente » Cod sursa (job #2136589) | Cod sursa (job #1539935) | Cod sursa (job #2033521) | Cod sursa (job #629630) | Cod sursa (job #1884387)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
const int MaxN=105;
int n, rf[MaxN][MaxN];
int main()
{
fin>>n;
for(int i=1;i=n;++i)
for(int j=1;j<=n;++j)
fin>>rf[i][j];
for(int k=1;k<=n;++k)
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
if(rf[i][j]>rf[i][k]+rf[k][j])
rf[i][j]=rf[i][k]+rf[k][j];
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
{fout<<rf[i][j]<<' ';
fout<<'\n';}
return 0;
}