求通用函数定积分的c程序
发布时间:2019-08-13 12:44
给你个参考代码,具体如下:
#include <stdio.h>
#define RES (1e-6)
double integ(double a,double b,double f(double))
{
double sum;
for(sum=0;a<b;a+=RES)
{
sum+=f(a)*RES;
}
return sum;
}
double f(double x)
{
return x*x;
}
int main()
{
printf("%lf\n",integ(0,0.1,f));
return 0;
}