正确结果应该是1.100000为什么运行结果是1.000000
#include<stdio.h>
#include<math.h>
double fun(double x)
{
int i;
double s[]={0},sum;
sum=s[0]=1;
for(i=1;fabs(s[i])>=0.000001;i++)
{
s[i]=(0.5-i+1)*x/i*s[i-1];
sum+=s[i];
}
return sum;
}
int main()
{
double x,s;
printf("Input x:\n");
printf("0.21\n");
s=fun(0.21);
printf("s=%f\n",s);
}