1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
const int NB_SOMMETS_MAX = 1000;
const int nbIterations = 100;
const int nbFourmis = 100;
class graph
{
public:
int nbSommets;
long double distance[NB_SOMMETS_MAX][NB_SOMMETS_MAX];
long double visibilite[NB_SOMMETS_MAX][NB_SOMMETS_MAX];
int solution[NB_SOMMETS_MAX];
long double longueurSolution;
void lireEntree()
{
cin >> nbSommets;
long double coords[nbSommets][2];
for (int i = 0 ; i < nbSommets ; i++)
cin >> coords[i][0] >> coords[i][1];
for (int i = 0 ; i < nbSommets ; i++)
for (int j = i ; j < nbSommets ; j++)
{
long double curDist = sqrt(pow(coords[i][0]-coords[j][0],2)+pow(coords[i][1]-coords[j][1],2));
distance[i][j] = distance[j][i] = curDist;
visibilite[i][j] = visibilite[j][i] = 1/curDist;
}
}
void printParcours()
{
for (int i = 0 ; i < nbSommets ; i++)
cout << solution[i] << " ";
cout << endl;
cout << "L=" << longueurSolution;
}
};
int main()
{
cout.precision(16);
graph g;
g.lireEntree();
return 0;
} |