Skip to content
Snippets Groups Projects
Commit 1678e946 authored by Miguel Espino's avatar Miguel Espino
Browse files

fixed make file errors on complexComp.c

parent e4947d65
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <qsort.h> #include <qsort.h>
#include <math.h>
/* returns -1 if first < second /* returns -1 if first < second
* returns 0 if first == second * returns 0 if first == second
* returns 1 if first > second * returns 1 if first > second
...@@ -19,18 +19,27 @@ ...@@ -19,18 +19,27 @@
* a complex number is composed of 2 fields: real and imaginary, which are * a complex number is composed of 2 fields: real and imaginary, which are
* both doubles * both doubles
*/ */
typedef struct {
double real;
double imag;
} Complex;
int compareComplex(void *first, void *second) int compareComplex(void *first, void *second)
{ {
Complex *cFirst; Complex *cFirst;
char *index; char *index;
Complex *cSnd; Complex *cSnd;
int sizeFirst, sizeSecond; int sizeFirst, sizeSecond;
cFirst->real = strtod(first, &index, 10); cFirst = malloc(sizeof(Complex));
cFirst->imag = strtod(index, NULL, 10); cSnd = malloc(sizeof(Complex));
cSnd->real = strtod(second, &index, 10);
cSnd->imag = strtod(index, NULL, 10);
cFirst->real = strtod(first, &index);
cFirst->imag = strtod(index, NULL);
cSnd->real = strtod(second, &index);
cSnd->imag = strtod(index, NULL);
sizeFirst = sqrt(cFirst->real * cFirst->real + cFirst->imag * cFirst->imag); sizeFirst = sqrt(cFirst->real * cFirst->real + cFirst->imag * cFirst->imag);
sizeSecond = sqrt(cSnd->real * cSnd->real + cSnd->imag * cSnd->imag); sizeSecond = sqrt(cSnd->real * cSnd->real + cSnd->imag * cSnd->imag);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment