13,825
社区成员
发帖
与我相关
我的任务
分享
for(;fabs(temp)>=1e-6;)
#include<stdio.h>
#include<math.h>
int main()
{
int i=1;
double temp=1,sum=1,x;
scanf("%lf",&x);
while(fabs(temp)>=1e-6)
{
temp = temp*x/i;
sum += temp;
temp = -temp;
i++;
}
printf("%lf\n",sum);
return 0;
}