请问这个C++程序有什么错误?(求f(x) = x^2+5x-6在【3,5】区间上的积分值.)#include using namespace std;int main(){double n = (5 - 3) / 100,sum = 0; for (double beg = 3,end = beg + n,y1,y2; beg

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 21:51:14

请问这个C++程序有什么错误?(求f(x) = x^2+5x-6在【3,5】区间上的积分值.)#include using namespace std;int main(){double n = (5 - 3) / 100,sum = 0; for (double beg = 3,end = beg + n,y1,y2; beg
请问这个C++程序有什么错误?(求f(x) = x^2+5x-6在【3,5】区间上的积分值.)
#include
using namespace std;
int main()
{
double n = (5 - 3) / 100,sum = 0;
for (double beg = 3,end = beg + n,y1,y2; beg

请问这个C++程序有什么错误?(求f(x) = x^2+5x-6在【3,5】区间上的积分值.)#include using namespace std;int main(){double n = (5 - 3) / 100,sum = 0; for (double beg = 3,end = beg + n,y1,y2; beg
double n = (5 - 3) / 100,sum = 0; 该为double n = (5 - 3) / 100.0,
sum += (y1 + y2) * n / 2改为sum += (y1 + y2) * n / 2.0
这样计算出来的结果才是小数,不然计算结果是整数.