Pagini recente » Cod sursa (job #2505004) | Cod sursa (job #2298726) | Cod sursa (job #3261799) | Cod sursa (job #2308729) | Cod sursa (job #2628097)
#include <bits/stdc++.h>
using namespace std;
/******************************************/
ifstream f("royfloyd.in");
ofstream g("royfloyd.out");
/******************************************/
//variabile globale
int n;
int dist[101][101];
/******************************************/
///---------------------------------------------
inline void readInput()
{
f>>n;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++) f>>dist[i][j];
}
}
///---------------------------------------------
inline void Solution()
{
for(int k=1;k<=n;k++)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(dist[i][j] > dist[i][k] + dist[k][j])
{
dist[i][j] = dist[i][k] + dist[k][j];
}
}
}
}
}
///---------------------------------------------
inline void Afisare()
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++) g<<dist[i][j]<<" ";
g<<"\n";
}
}
///---------------------------------------------
int main()
{
readInput();
Solution();
Afisare();
return 0;
}