Mai intai trebuie sa te autentifici.
Cod sursa(job #1992019)
| Utilizator | Data | 19 iunie 2017 02:49:27 | |
|---|---|---|---|
| Problema | Floyd-Warshall/Roy-Floyd | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.78 kb |
#include <fstream>
#define Vmax 100
using namespace std;
int main()
{
ifstream input("royfloyd.in");
ofstream output("royfloyd.out");
int V;
input >> V;
int i, j, k;
int dist[Vmax][Vmax];
for(i = 0; i < V; i ++)
for(j = 0; j < V; j ++)
dist[i][j] = 1 << 16;
for(i = 0; i < V; i ++)
for(j = 0; j < V; j ++)
input >> dist[i][j];
for(k = 0; k < V; k ++)
for(i = 0; i < V; i ++)
for(j = 0; j < V; j ++)
if(dist[i][j] > dist[i][k] + dist[k][j])
dist[i][j] = dist[i][k] + dist[k][j];
for(i = 0; i < V; i ++)
{
for(j = 0; j < V; j ++)
output << dist[i][j] << ' ';
output << '\n';
}
return 0;
}
