求定积分程序,10000是题目给出的值,样例中是输入12.3 16.8,输出960.2550,而我的这个输出的是960.2255
#include
int main()
{
double a, b;
double x, y, s, h;
scanf_s("%lf %lf", &a, &b);
s = 0;
h = (b - a) / 10000;
x = a;
for (;x <= b;)
{
y = x * x;
s += y * h;
x = x + h;
}
printf("%.4lf", s);
return 0;
}
题目贴出来,估计你少加了一次吧