你自己看看结果对不对
fun(float x,int n)
{
int a=-1; /*标志*/
int i,j,k;
float b=1,c=1,sum=0;
for(i=1;i<=n;i++)
{
for(j=1;j<=2*i;j++)
b*=x; /*
求 x的2n 次*/
for(k=1;k<=2*i;k++)
c*=k;
/*
求x的(2n)!*/
sum+=a*b/c;
a*=-1;
b=1;
c=1;
}
return sum;
}
main()
{
float x;int n;
float sum;
printf("%s","please input x ,then n\n");
scanf("%f%d",&x,&n);
sum=fun(x,n);
printf("the sum is %f",sum);
}