|
|
back to boardPlease, help me! I've got Compilation Error ???? #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <utility> using namespace std; const int maxN = 304; int x[maxN], y[maxN]; int n; vector< pair<int, int> > p; bool mark[maxN][maxN]; int dist(const int& i, const int& j) { return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]); } bool compairation(const pair<int, int>& p1, const pair<int, int>& p2) { return (dist(p1.first, p1.second) > dist(p2.first, p2.second)); } int ccw(const int& i, const int& j, const int& k) { int dx1 = x[j] - x[i], dy1 = y[j] - y[i]; int dx2 = x[k] - x[j], dy2 = y[k] - y[j]; return (dx1 * dy2 - dx2 * dy1); } int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
for (int i = 1; i < n; i++) for (int j = i + 1; j <= n; j++) p.push_back(pair<int, int>(i, j)); sort(p.begin(), p.end(), compairation);
memset(mark, true, sizeof(mark));
double total = 0.0; for (int i = 0; i < p.size(); i++) if (mark[p[i].first][p[i].second]) { int d = p[i].first, c = p[i].second; vector<int> point; point.clear(); for (int j = 1; j <= n; j++) if (ccw(d, j, c) == 0) point.push_back(j); for (int u = 0; u < point.size(); u++) for (int v = u + 1; v < point.size(); v++) { mark[point[u]][point[v]] = false; mark[point[v]][point[u]] = false; //cout << point[u] << " " << point[v] << endl; } total += sqrt(double(dist(d, c))); }
cout << round(total) << endl;
return 0; } Re: Please, help me! I've got Compilation Error ???? cout << round(total) << endl;//<Mistake here There is no function round() in C++. Edited by author 01.02.2008 02:11 Re: Please, help me! I've got Compilation Error ???? Or try follow: Set #include<stdio.h> and write printf("%0.lf",total); I think it will be more helpful. Edited by author 01.02.2008 01:42 Edited by author 01.02.2008 02:11 Re: Please, help me! I've got Compilation Error ???? Thank you very much! I've got AC. But i compiled it sucessfully by DevC++ and Eclipse IDE. (It also uses g++ compiler). Please tell me why ????? Edited by author 01.02.2008 19:05 Re: Please, help me! I've got Compilation Error ???? As far as I know there is no standart function round() in C++.For more information read FAQ.Good luck! |
|
|