implement divide and conquer

This commit is contained in:
2018-12-12 18:48:54 -03:00
parent e37384d18f
commit 6ac113d408
4 changed files with 159 additions and 73 deletions

View File

@@ -30,7 +30,7 @@
* @param d2 El segudno double
* @return Retorna 1 si son igual o 0 sino
*/
int compare_double(double d1, double d2) {
inline int compare_double(double d1, double d2) {
double precision = 0.000000001;
if (((d1 - precision) < d2) && ((d1 + precision) > d2)) {
return 1;
@@ -72,7 +72,7 @@ int main(int argc, char **argv) {
fprintf(stdout, "\tbrute force: ");
fflush(stdout);
brute_force(points, n, &dist);
if (compare_double(dist, 0.067687840)) {
if (compare_double(sqrt(dist), 0.067687840)) {
fprintf(stdout, "passed\n");
passed++;
}
@@ -90,7 +90,7 @@ int main(int argc, char **argv) {
fprintf(stdout, "\tdivide and conquer: ");
fflush(stdout);
divide_and_conquer(points, n, &dist);
if (compare_double(dist, 0.067687840)) {
if (compare_double(sqrt(dist), 0.067687840)) {
fprintf(stdout, "passed\n");
passed++;
}