编写一个用矩形法求定积分,这个程序哪里出错了.答案总是显示0#include"stdio.h"#include"math.h"doublefun1 (double x){return (sin (x));}doublefun2 (double x){return (cos (x));}doublefun3 (double x){return (exp (x));}doublejifen (
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/04 16:18:44
编写一个用矩形法求定积分,这个程序哪里出错了.答案总是显示0#include"stdio.h"#include"math.h"doublefun1 (double x){return (sin (x));}doublefun2 (double x){return (cos (x));}doublefun3 (double x){return (exp (x));}doublejifen (
编写一个用矩形法求定积分,这个程序哪里出错了.答案总是显示0
#include"stdio.h"
#include"math.h"
double
fun1 (double x)
{
return (sin (x));
}
double
fun2 (double x)
{
return (cos (x));
}
double
fun3 (double x)
{
return (exp (x));
}
double
jifen (double (*p) (double x),int a,int b)
{
int i;
double f = 0.0,h,x,y1,y2,area;
h = (b - a) / 10000;
x = a;
y1 = (*p) (x);
for (i = 1; i
编写一个用矩形法求定积分,这个程序哪里出错了.答案总是显示0#include"stdio.h"#include"math.h"doublefun1 (double x){return (sin (x));}doublefun2 (double x){return (cos (x));}doublefun3 (double x){return (exp (x));}doublejifen (
我这上面测试的时候发现的问题是在
f = (b-a)/10000;这里
因为a,b都是整形,所以如果b-a