Pagini recente » Cod sursa (job #1967194) | Cod sursa (job #1515012) | Cod sursa (job #1960602) | Cod sursa (job #1124121) | Cod sursa (job #3284127)
#include <fstream>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <set>
#include <cstring>
#include <map>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#define oo 2000000
#define MOD 1000000007
using namespace std;
ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");
int a[105][105], n;
int main()
{
fin >> n;
for(int i=1;i<=n;i++)
for (int j = 1; j <= n; j++)
{
fin >> a[i][j];
}
for (int k = 1; k <= n; k++)
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (a[i][j] > a[i][k] + a[k][j])
a[i][j] = a[i][k] + a[k][j];
for (int i = 1; i <= n; i++,fout<<endl)
for (int j = 1; j <= n; j++)
fout << a[i][j] << " ";
}