# 计算sin(x)

计算sin(x)=x-x^3/3!+x^5/5!-X^7/7!+......,直到最后一项的绝对值小于10-7时停止计算。其中-2Π<=x<=2Π，^表示次方，如x^3表示x的3次方。

**输入**

一个实数x，-2Π<=x<=2Π

**输出**

sin(x)的值

**输入样例**

```json
3.142
```

**输出样例**

```json
-0.000407347
```

以下程序实现了这一功能，请你填补空白处内容：

```cpp
#include <stdio.h>
#include <math.h>
double sin(double);
double nResult(double, double);
int main()
{
    double x = 0;
    scanf("%lf", &x);
    printf("sin(%lf)=%lf\n", x, sin(x));
    return 0;
}
double sin(double x)
{
    int i = 0;
    double result = 0, n = 0;
    ____________________;
    return result;
}
double nResult(double x, double n)
{
    return n == 1 ? x : nResult(x, n - 1) * x / n;
}
```

## template

```cpp
#include <stdio.h>
#include <math.h>
double sin(double);
double nResult(double, double);
int main()
{
    double x = 0;
    scanf("%lf", &x);
    printf("sin(%lf)=%lf\n", x, sin(x));
    return 0;
}
double sin(double x)
{
    int i = 0;
    double result = 0, n = 0;
    while (fabs(n = nResult(x, 2 * ++i - 1)) > 0e-7)
        result += (i % 2 == 1) ? n : -n;
    return result;
}
double nResult(double x, double n)
{
    return n == 1 ? x : nResult(x, n - 1) * x / n;
}
```

## 答案

```cpp
while (fabs(n = nResult(x, 2 * ++i - 1)) > 0e-7)
	result += (i % 2 == 1) ? n : -n;
```

## 选项

### A

```cpp
while (fabs(n = nResult(x, 2 * i - 1)) > 0e-7)
	result += (i % 2 == 1) ? n : -n;
```

### B

```cpp
while (fabs(n = nResult(x, 2 * i++ - 1)) > 0e-7)
	result += (i % 2 == 1) ? n : -n;
```

### C

```cpp
while (fabs(n = nResult(x, 2 * ++i + 1)) > 0e-7)
	result += (i % 2 == 1) ? n : -n;
```