大众信息网

用vf程序编写梯形法求积分 举个例子

答案:1  mip版
解决时间 2021-08-02 22:00
  • 提问者网友:葃日懙妳
  • 2021-08-01 21:52
用vf程序编写梯形法求积分 举个例子
最佳答案
  • 二级知识专家网友:魔法小仙子
  • 2021-08-01 22:46

#include <iostream>
#include <cmath>
using std::cout;
using std::endl;

double fun(double x){
return sin(x)+exp(x);
}

int main(){
double result=0;
double x=0;
double h=1e-6;
while(x<1){
result+=fun(x);
x+=h;
}
result*=h;
cout<<result<<endl;
return 0;
}


试试吧


我要举报
如以上问答内容为低俗/色情/暴力/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!
点此我要举报以上问答信息
推荐资讯