33 lines
520 B
C
33 lines
520 B
C
#include <stdio.h>
|
|
#include <math.h>
|
|
|
|
int main ()
|
|
{
|
|
double x, power, result;
|
|
int n, neg_one;
|
|
|
|
printf("Input n (must be an integer): ");
|
|
scanf(" %d", &n);
|
|
|
|
printf("Input x (a number with a floating decimal point): ");
|
|
scanf(" %lf", &x);
|
|
|
|
result = 1;
|
|
neg_one = -1;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
power = pow(x, 2*i + 1);
|
|
|
|
neg_one *= -1;
|
|
|
|
result *= (power*neg_one) / (2*i + 1);
|
|
}
|
|
|
|
// result_cos *= x;
|
|
|
|
printf("Y = %f\n", result);
|
|
|
|
return 0;
|
|
}
|