#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

double Integral(double (*f)(double), int n, double a, double b)
{
   double h= (b-a)/n;
   double s= 0.0;

   for (int k=0; k<n; k++)
      s+= f(a+k*h);

   return h*s;
}

double cube(double x)
{
   return x*x*x;
}

int main(int nargs, char* args[])
{
   double (*r[3])(double) = { sin, cos, cube };
   for (int k=0; k<3; k++)
      cout << Integral(r[k], 1024, 0, M_PI) << endl;
   system("PAUSE");
   return EXIT_SUCCESS;
}

