a few small fixes

This commit is contained in:
Chris Cromer 2018-12-12 12:03:16 -03:00
parent 2e3d2b43ee
commit daf9d6cc4a
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A

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;
}