∫1/(1+x^2)dx 程序为
0
main()
{int i,n;
float h,a,b,e,x,sum1,sum2,c,d,f;
a=0.0;b=1.0;
printf("input n:");//n为将区间分为多少份
scanf("%d",&n);
h=(b-a)/(6.0*n);
sum1=0;
for(i=2;i<2*n;)
{x=i/(2*n);
e=1+x*x;
sum1=sum1+e;
i=i+2;
}
d=sum1;
sum2=0;
for(i=3;i<2*n;)
{x=i/(2*n);
e=1+x*x;
sum2=sum2+e;
i=i+2;
}
f=sum2;
c=h*(1+a*a+4*d+2*f+1+b*b);
printf("%6.5f",c);
}
剩下的那个也类似
∫1/(1+x^2)dx 程序为
0
main()
{int i,n;
float h,a,b,e,x,sum1,sum2,c,d,f;
a=0.0;b=1.0;
printf("input n:");//n为将区间分为多少份
scanf("%d",&n);
h=(b-a)/(6.0*n);
sum1=0;
for(i=2;i<2*n;)
{x=i/(2*n);
e=1+x*x;
sum1=sum1+e;
i=i+2;
}
d=sum1;
sum2=0;
for(i=3;i<2*n;)
{x=i/(2*n);
e=1+x*x;
sum2=sum2+e;
i=i+2;
}
f=sum2;
c=h*(1+a*a+4*d+2*f+1+b*b);
printf("%6.5f",c);
}
楼主要求的函数指针在哪儿呢?空中鱼朋友!