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; }
最多设置5个标签!
给你个参考代码,具体如下:
#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; }
一周热门 更多>