From 0b40aa3bb5c635f253d300e8e2885f751848bed8 Mon Sep 17 00:00:00 2001 From: pjungeblut Date: Sat, 25 Oct 2014 17:50:23 +0200 Subject: adding makefile --- geometry/closestPair.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'geometry/closestPair.cpp') diff --git a/geometry/closestPair.cpp b/geometry/closestPair.cpp index 10c9291..92b4551 100644 --- a/geometry/closestPair.cpp +++ b/geometry/closestPair.cpp @@ -1,15 +1,13 @@ double squaredDist(point a, point b) { - return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); + return (a.first-b.first) * (a.first-b.first) + (a.second-b.second) * (a.second-b.second); } bool compY(point a, point b) { - if (a.second == b.second) { - return a.first < b.first; - } + if (a.second == b.second) return a.first < b.first; return a.second < b.second; } -void shortestDist(vector &points) { +double shortestDist(vector &points) { //check that points.size() > 1 and that ALL POINTS ARE DIFFERENT set status(compY); sort(points.begin(), points.end()); @@ -33,5 +31,6 @@ void shortestDist(vector &points) { } status.insert(*(right++)); } - } // closest distance in sqrtOpt + } + return sqrtOpt; } -- cgit v1.2.3