#include <stdio.h>
#include <math.h>

double fun(double x){
//       return exp(x)-2.0; 
//       return 0.5-cos(x);

//         return x-cos(x);

           return x;
}


main(){
       double a=0.0, b=1.0;
       int n=1;
       for(;n>0;n=2*n)
       {
       
        double dx=(b-a)/(double)n;
        
        
        // Integral calculated at the right end point
        double integralup=0.0;
        
        // Integral calculated at the left end point
        double integrallo=0.0;
        
        int k;
        double ckl=a,cku=a;
        for(k=1;k<=n;k++)
        {
         cku=cku+dx;
         integralup=integralup+fun(cku);
         integrallo=integrallo+fun(ckl);
         ckl=ckl+dx;
        
        }
        
        printf("%10d %1.12lf %1.12lf",n,integrallo*dx,integralup*dx);
        getchar();
       
       }
       getchar();
       getchar();
       
       return 0;
}
