c语言大神求救啊
#include<stdio.h>#include<math.h>doublefun(doublex){}main(){doublex,s;voidNONO();prin...
#include <stdio.h>#include <math.h>double fun (double x){
}main(){ double x,s ; void NONO(); printf(“Input x: ”); scanf (“%lf”,&x); s=fun(x); printf(“s=%f\n”,s); NONO() }void NONO(){/*请在此函数内打开文件,输入测试数据,调用 fun 函数,输出数据,关闭文件。*/ FILE *rf, *wf ,int I ;double s, x; rf = fopen (“K:\\k28\\24100140\\in.dat”,”r”); wf = fopen (“K:\\k28\\24100140\\out.dat”,”w”); for (i=0;i<10;i++) { fascanf(rf,”%if”,&x); s=fun (x); fprintf(wf,”%if\n”,s); } fclose (rf); fclose(wf);} 展开
}main(){ double x,s ; void NONO(); printf(“Input x: ”); scanf (“%lf”,&x); s=fun(x); printf(“s=%f\n”,s); NONO() }void NONO(){/*请在此函数内打开文件,输入测试数据,调用 fun 函数,输出数据,关闭文件。*/ FILE *rf, *wf ,int I ;double s, x; rf = fopen (“K:\\k28\\24100140\\in.dat”,”r”); wf = fopen (“K:\\k28\\24100140\\out.dat”,”w”); for (i=0;i<10;i++) { fascanf(rf,”%if”,&x); s=fun (x); fprintf(wf,”%if\n”,s); } fclose (rf); fclose(wf);} 展开
展开全部
很简单
double fun (double x)
{
double f, t; int n;
f=1.0+x;
t=x;
n=1;
do{
n++;
t *= (x-n+1)/n;
f += t;
}
while (fabs(t)>=1e-6);
return f;
}
double fun (double x)
{
double f, t; int n;
f=1.0+x;
t=x;
n=1;
do{
n++;
t *= (x-n+1)/n;
f += t;
}
while (fabs(t)>=1e-6);
return f;
}
更多追问追答
追问
亲 不行啊 运行不起来啊
追答
不是上面错误
你下面很多中文,改正
#include
#include
double fun (double x)
{
double f, t; int n;
f=1.0+x;
t=x;
n=1;
do{
n++;
t *= (x-n+1)/n;
f += t;
}
while (fabs(t)>=1e-6);
return f;
}
void main()
{
double x,s ;
void NONO();
printf("Input x: "); scanf ("%lf",&x);
s=fun(x);
printf("s=%f\n",s);
NONO() ;
}
void NONO()
{/*请在此函数内打开文件,输入测试数据,调用 fun 函数,输出数据,关闭文件。*/
FILE *rf, *wf ;
int i ;
double s, x;
rf = fopen ("K:\\k28\\24100140\\in.dat","r");
wf = fopen ("K:\\k28\\24100140\\out.dat","w");
for (i=0;i<10;i++)
{
fscanf(rf,"%if",&x);
s=fun (x);
fprintf(wf,"%if\n",s);
}
fclose (rf); fclose(wf);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询