double rectangle_method( double (*f)(double), double a, double b,
unsigned int n)
{
if (n == 0)
return 0.0;
double sum = 0.0;
double h = (b - a) / n;
for (unsigned int i = 0; i < n; i++)
sum += f(a + (i + 0.5) * h);
return h * sum;
}
int main(){
double x;
cout<<setprecision(11) <<rectangle_method(f,1,5,100)<<endl;
return 0;
}