include stdio include stdlib int main void int double sum slag 1e-4 pr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int n=1;
double x,sum,slag,g,e=1e-4;
printf("print -1<=x<=1\n");
scanf("%lf", &x);
g=-x*x;
slag=g/2;
sum=slag;
if ((x<=1)&&(x>=-1))
{
while(slag>e || slag<-e)
{
slag*=g/(n+1);
sum+=slag;
n++;
}
printf ("sum = %lf\n", sum);
}
system("PAUSE");
return 0;
}