请大佬指导,计算题
#include <stdio.h>#include <math.h>
double funcos( double e, double x );
int main()
{
double e, x;
scanf("%lf %lf", &e, &x);
printf("cos(%.2f) = %.6f\n", x, funcos(e, x));
return 0;
}
double funcos( double e, double x )
{
int numerator,denominator,flag,i;
double item,sum;
i=1;
flag=-1.0;
denominator=2;
numerator=x*x;
sum=0;
do
{
item=flag*numerator/denominator;
sum=sum+item;
numerator=numerator*x*x;
denominator=denominator*(denominator+1)*(denominator+2);
flag=-flag;
}while(fabs(item)>=e);
return sum;
}//输入0.01 -3.14 为什么得不到-0.999899