Cod sursa(job #1856519)

Utilizator razvanlgu31Razvan Lungu razvanlgu31 Data 24 ianuarie 2017 23:50:25
Problema Floyd-Warshall/Roy-Floyd Scor 50
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>

using namespace std;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
int d[110][110],n,m,i,c,j,k,x,y;
int main()
{
    fin>>n;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            fin>>d[i][j];
        }
    }
    for(k=1; k<=n; k++)
        for(i=1; i<=n; i++)
            for(j=1; j<=n; j++)
                if(d[i][j]>d[i][k]+d[k][j])
                    d[i][j]=d[i][k]+d[k][j];
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {

                fout<<d[i][j]<<" ";
        }
        fout<<'\n';
    }
    return 0;
}