Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CMPT332-LFC083-LAB0
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Migz Espino (lfc083)
CMPT332-LFC083-LAB0
Commits
1678e946
Commit
1678e946
authored
3 months ago
by
Miguel Espino
Browse files
Options
Downloads
Patches
Plain Diff
fixed make file errors on complexComp.c
parent
e4947d65
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
complexComp.c
+15
-6
15 additions, 6 deletions
complexComp.c
with
15 additions
and
6 deletions
complexComp.c
+
15
−
6
View file @
1678e946
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment