Pagini recente » Cod sursa (job #2554528) | Cod sursa (job #2502063) | Cod sursa (job #1521200) | Cod sursa (job #1163795) | Cod sursa (job #2341532)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
int N, cost, matrice[105][105];
int main()
{
fin >> N;
for(int i = 1; i <= N; i++){
for(int j = 1; j <= N; j++){
fin >> cost;
matrice[i][j] = cost;
}
}
for(int k = 1; k <= N; k++){
for(int i = 1; i <= N; i++){
for(int j = 1; j <= N; j++){
matrice[i][j] = min(matrice[i][j], matrice[i][k] + matrice[k][j]);
}
}
}
for(int i = 1; i <= N; i++){
for(int j = 1; j <= N; j++){
fout << matrice[i][j] << " ";
}
fout << "\n";
}
}