函数fun是根据输入n,求数列s=1/2- (1/2) * (3/4)+(1/2) * (3/4) * (5/6)-(1/2) * (3/4) * (5/6) * (7/8)+. . . 前n项的和 ,
例如输入10 ,结果输出为0.206936。要求在/Begin/与/End/之间编写程序,其它部分不得增删语句。
#include<stdio.h>
#include<stdlib.h>
double fun(int n)
{
/Begin/
/End/
}
int main()
{
int n;
double s;
FILE *in,*out;
printf("输入n:");
scanf("%d",&n);
s=fun(n);
printf("%lf\n",s)
in=fopen("in2019-2-3-2.dat","r");
out=fopen("out2019-2-3-2.dat","w");
while(!feof(in))
{
fscanf(in,"%d",&n);
fprintf(out,"%lf\n",fun(n));
}
fclose(in);
fclose(out);
system("pause");
return 0;
}