Cod sursa(job #1994147)

Utilizator teo.cons98Constantin Teodor-Claudiu teo.cons98 Data 24 iunie 2017 11:35:16
Problema Floyd-Warshall/Roy-Floyd Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.91 kb
#include <iostream>
#include <fstream>
#include <vector>


using namespace std;

ifstream fin("royfloyd.in");
ofstream fout("royfloyd.out");

unsigned int nrNoduri, nrMuchii;

vector < vector < int > > A;

void citire()
{
	fin >> nrNoduri;

	A.resize(nrNoduri);
	for (int i = 0; i < nrNoduri; ++i)
	{
		A[i].resize(nrNoduri);

		for (int j = 0; j < nrNoduri; ++j)
		{
			fin >> A[i][j];

			if (A[i][j] == 0 && i != j)
			{
				A[i][j] = 999999;
			}
		}
	}


}

int main()
{
	citire();
	for (int k = 0; k < nrNoduri; ++k)
	{
		for (int i = 0; i < nrNoduri; ++i)
		{
			for (int j = 0; j < nrNoduri; ++j)
			{
				if (A[i][j] > A[i][k] + A[k][j])
				{
					A[i][j] = A[i][k] + A[k][j];
				}
			}
		}
	}

	for (int i = 0; i < nrNoduri; ++i)
	{
		for (int j = 0; j < nrNoduri; ++j)
		{
			fout << A[i][j] << " ";
		}
		fout << '\n';
	}

	while (true)
	{

	}

}