----------------解决方案--------------------------------------------------------
楼主以后自己多想,程序可以更精简(但没必要)
[CODE]
#include "stdio.h"
#include "math.h"
double Exps(float x)
{
int i=0;
double sum=0,condition=1;
for(i=0;fabs( condition )>=0.000001;i++)
{
sum+=condition;
condition=condition*x/(i+1);
}
return sum;
}
int main ()
{
float x;
scanf("%f",&x);
printf("The result is %lf\n",( Exps(x)+Exps(-x) )/2);
return 0;
}
[/CODE]
----------------解决方案--------------------------------------------------------