equal
deleted
inserted
replaced
8 #include <math.h> |
8 #include <math.h> |
9 |
9 |
10 double *getValues (int elements) |
10 double *getValues (int elements) |
11 { |
11 { |
12 double *values; |
12 double *values; |
|
13 |
13 int i; |
14 int i; |
14 |
15 |
15 if ((values = calloc (elements + 1, sizeof (double))) == NULL) |
16 if ((values = calloc (elements + 1, sizeof (double))) == NULL) |
16 return NULL; |
17 return NULL; |
17 for (i = elements; i >= 0; i--) |
18 for (i = elements; i >= 0; i--) |
22 #define MAX 40 |
23 #define MAX 40 |
23 |
24 |
24 int main (int argc, char **argv) |
25 int main (int argc, char **argv) |
25 { |
26 { |
26 double *values = getValues (MAX); |
27 double *values = getValues (MAX); |
|
28 |
27 int i; |
29 int i; |
28 |
30 |
29 for (i = 0; i < MAX; i++) { |
31 for (i = 0; i < MAX; i++) { |
30 if (fabs (cos (i) - values[i]) < 0.001) |
32 if (fabs (cos (i) - values[i]) < 0.001) |
31 printf ("COS(%d) = %3.2g = %3.2g\n", i, values[i], cos (i)); |
33 printf ("COS(%d) = %3.2g = %3.2g\n", i, values[i], cos (i)); |