Browse Source

a few small fixes

pull/3/head
Chris Cromer 2 years ago
parent
commit
daf9d6cc4a
Signed by: cromer GPG Key ID: 39CC813FF3C8708A
1 changed files with 18 additions and 9 deletions
  1. +18
    -9
      src/points.c

+ 18
- 9
src/points.c View File

@ -23,6 +23,7 @@
#include "timer.h"
#include "read_file.h"
#include "brute_force.h"
#include "divide_and_conquer.h"
#define POINTS_VERSION "1.0.0"
@ -163,20 +164,28 @@ int main (int argc, char **argv) {
start_algorithm("Brute force corriendo... ", n);
closest_points = brute_force(points, n, &dist);
end_algorithm();
printf("point 1: x: %f y: %f\n", closest_points[0].x, closest_points[0].y);
printf("point 2: x: %f y: %f\n", closest_points[1].x, closest_points[1].y);
printf("distance: %lf\n\n", dist);
fprintf(stdout, "point 1: x: %f y: %f\n", closest_points[0].x, closest_points[0].y);
fprintf(stdout, "point 2: x: %f y: %f\n", closest_points[1].x, closest_points[1].y);
fprintf(stdout, "distance: %lf\n\n", dist);
free(closest_points);
closest_points = NULL;
}
if (divide) {
start_algorithm("Divide and conquer corriendo... ", n);
closest_points = divide_and_conquer(points, n, &dist);
end_algorithm();
printf("point 1: x: %f y: %f\n", closest_points[0].x, closest_points[0].y);
printf("point 2: x: %f y: %f\n", closest_points[1].x, closest_points[1].y);
printf("distance: %lf\n", dist);
if (n <= 3) {
fprintf(stderr, "Divide and conquer necesita 4 o mas puntos!\nSe utilizará Brute Force como alternativa!\n");
start_algorithm("Brute force corriendo... ", n);
closest_points = brute_force(points, n, &dist);
end_algorithm();
}
else {
start_algorithm("Divide and conquer corriendo... ", n);
closest_points = divide_and_conquer(points, n, &dist);
end_algorithm();
}
fprintf(stdout, "point 1: x: %f y: %f\n", closest_points[0].x, closest_points[0].y);
fprintf(stdout, "point 2: x: %f y: %f\n", closest_points[1].x, closest_points[1].y);
fprintf(stdout, "distance: %lf\n", dist);
free(closest_points);
closest_points = NULL;
}


Loading…
Cancel
Save