C语言编程题,题目已附上!求解
顺便帮忙看看哪里错了,写了,写份正确的给我吧
# include<stdio.h>
# include<math.h>
int main(void)
{
double e,cosx,x;
double funcos(double e,double x);
printf("Enter e:");
scanf("%lf",&e);
printf("Enter x:");
scanf("%d",&x);
cosx=funcos(e);
printf("cosx=%.4f\n",cosx);
return 0;
}
double funcos(double e)
{
int flag,i,n,j,x;
double item,sum,power,result;
for(i=0;i<=n;i=i+2){
power=pow(x,i);
}
for(j=0;j<=n;j=j+2){
result=result*j;
}
flag=1;
item=1.0;
sum=0;
while(fabs(item)>=e){
item=flag*power/result;
sum=sum+item;
flag=-flag;
result=result+2;
}
return 0;
}