按下面的公式求s的近似值,直到最后一项的项值绝对值小于x为止,x的值由键盘输入,结果保留4位小数.
S=1-1/3+1/5-1/7+.+(-1)*(n-1)*1/(2n-1)
例如:当x=0.001时,结果为0.7849
在begin和end中间怎么编写!
#include"stdio.h"
#include"math.h"
#include"stdlib.h"
doublefun(doublex)
{
//
}
voidmain()
{
doublex,sum;
printf("Enterx:n");
scanf("%lf",&x);
sum=fun(x);
printf("sum=%.4fn",sum);
NONO();
}
NONO()
{FILE*fr,*fw;
inti;
doublex;
fr=fopen("D:exam1910224PROGIN.DAT","r");
fw=fopen("D:exam1910224PROGOUT.DAT","w");
for(i=1;i