69,373
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
int main()
{
double s,t,i;
int x;
t=1.0,i=1.0,s=0.0;
printf("\n请输入x的值:");
scanf("%d",&x);
while(x != -1)
{
while(t>=1.0e-6)
{s+=t;
t=x*t/i;
i=i+1.0;
}
printf("answer=%.6f\n",s);
printf("\n请输入x的值:");
scanf("%d",&x);
}
}
//这样好像就可以了
#include <stdio.h>
int main() //main 最好符合规范,返回int
{
double s,x,t,i;
t=1.0,i=1.0,s=0.0;
printf("请输入x的值:");
scanf("%lf",&x); //%d输入整型,你这里应该是lf,输入double
while(t>=1.0e-6)
{
s+=t;
t=x*t/i;
i=i+1.0;
}
printf("answer=%.6f\n",s);
return 0;
}