大众信息网

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

关注:187  答案:1  手机版
解决时间 2021-08-02 22:00
用vf程序编写梯形法求积分 举个例子
最佳答案

#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;
}


试试吧


我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!