大神帮忙看一下我这个h的值为什么一直是0
#include <iostream>#include <cmath>
using namespace std;
double f(int a,int b,double (*p)(double x))
{
int i,n=1000;
double h,s=0.0;
h=(b-a)/n;
for(i=1;i<=n;i++)
s=s+h*p(a+i*h);
return s;
}
double f1(double x)
{
return x+1;
}
int main()
{
cout<<f(0,1,f1)<<endl;
return 0;
}