为什么 当float换为double时 计算结果总为1?
#include <stdio.h>
void main()
{
int n,i;
float x,exp = 1.0,s = 1.0,t = 1.0 ,m =1.0;
printf("请输入 x,n :\n");
scanf("%f %d",&x,&n);
for(i = 1; i<=n;i++)
{
m = m*i;
s = s*x;
t = s/m;
exp = exp + t ;
}
printf("%f",exp);
return ;
}
```c
#include <stdio.h>
void main()
{
int n,i;
double x,exp = 1.0,s = 1.0,t = 1.0 ,m =1.0;
printf("请输入 x,n :\n");
scanf("%f %d",&x,&n);
for(i = 1; i<=n;i++)
{
m = m*i;
s = s*x;
t = s/m;
exp = exp + t ;
}
printf("%lf",exp);
return ;
}
```