fix style and make pseudo code
This commit is contained in:
@@ -98,7 +98,7 @@ double divide_and_conquer_run(point_t *points_x, unsigned int nx, point_t *point
|
||||
points_y2[++left] = points_y[i];
|
||||
}
|
||||
else {
|
||||
points_y2[--right]= points_y[i];
|
||||
points_y2[--right] = points_y[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,8 @@ double divide_and_conquer_run(point_t *points_x, unsigned int nx, point_t *point
|
||||
d = sqrt(min_d);
|
||||
free(closest_pair2);
|
||||
|
||||
left = -1; right = ny;
|
||||
left = -1;
|
||||
right = ny;
|
||||
for (i = 0; i < ny; i++) {
|
||||
x = points_y[i].x - mid;
|
||||
if (x <= -d || x >= d) {
|
||||
@@ -144,12 +145,13 @@ double divide_and_conquer_run(point_t *points_x, unsigned int nx, point_t *point
|
||||
}
|
||||
|
||||
x1 = points_y2[left].y - d;
|
||||
for (i = right; i < ny && points_y2[i].y > x1; i++)
|
||||
for (i = right; i < ny && points_y2[i].y > x1; i++) {
|
||||
if ((x = distance(points_y2[left], points_y2[i])) < min_d) {
|
||||
min_d = x;
|
||||
closest_pair[0] = points_y2[left];
|
||||
closest_pair[1] = points_y2[i];
|
||||
}
|
||||
}
|
||||
left--;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user