De ce cand fac debug pe urmatorul cod in codeblocks:
/*
* File: main.cpp
* Author: petru
*
* Created on 2010-10-08
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#define LL long long
#define x first
#define y second
#define DN 1005
using namespace std;
typedef pair<int, int> PER;
typedef vector<PER > grafc;
grafc gr[DN];
int dist(const PER &a,const PER &b) {
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
int n;
PER coord[DN];
vector <int> sol;
int main()
{
ifstream f("desen.in");
ofstream g("desen.out");
f>>n;
for(int i=1; i<=n; ++i) {
double rez=0;
f>>coord[i].first>>coord[i].second;
for(int j=1; j<i; ++j) {
int d=abs(dist(coord[i],coord[j]));
gr[i].push_back(make_pair(j,d));
gr[j].push_back(make_pair(i,d));
sol.push_back(d);
}
if(i>1) {
sort(sol.begin(),sol.end());
for(int j=0;j<i-1; ++j)
rez+=sol[j];
}
if(rez)cout<<sqrt(rez)<<'\n';
else cout<<rez;
}
return 0;
}
La un moment dat primesc un ecran albastru pe care scrie ca pentru a nu-mi se strica windows-ul, acesta a fost oprit.
pentru debug folosesc testul asta: