指数函数

来源:百度文库 编辑:神马文学网 时间:2024/04/28 17:24:55
#include
using namespace std;
const double ERROR=0.00001;
float exp(float);
void main()
{
float x,y;
cin>>x;
y=exp(x);
cout<}
float exp(float x)
{
int i;
float f,m,y;
f=1;
m=1;
y=1;
i=1;
while(m/f>ERROR)
{
f=f*i;
m=m*x;
y=y+m/f;
i=i+1;
}
return y;
}