自己编的求函数积分程序,得到的结果却不甚理想,求高手解释和修改,拜托了
#include<stdio.h>#include<stdlib.h>
#include<math.h>
int main()
{
int f(double x);
int jifen(double a,double b,int n);
int m;
double x1,x2;
printf("请输入积分上下限及区间数:\n") ;
scanf("%lf%lf%d",&x1,&x2,&m);
printf("积分为:%10.3f\n",jifen(x1,x2,m));
system ("pause");
return 0;
}
int f(double x)
{
double f;
f=sin(2*x)+x;
return f;
}
int jifen(double a,double b,int n)
{
int f(double x);
double jifen=0.0;
int i;
for(i=1;i<=n;i++)
{
a=a+(b-a)/n;
jifen=jifen+f(a)*(b-a)/n;
}
return jifen;
}
输入 0 3.14159 10 得到的结果是0.000