#include <iostream>
#include <math.h>

using namespace std;

class analysis_module
{
public:
  virtual void process(float x[], float y[], int n) = 0;

};

class mean_rms_module : public analysis_module
{
public:
  virtual void process(float x[], float y[], int n);
};

class print_module : public analysis_module
{
public:
  virtual void process(float x[], float y[], int n);
};


void print_module::process(float x[], float y[], int n)
{
  for (int i=0; i<n; i++) {
    
    cout << "x=" << x[i] << "  y=" << y[i] << endl;
  }
}

void mean_rms_module::process(float x[], float y[], int n)
{
  float sumq=0;
  float sumq2=0;
  
  for (int i=0; i<n; i++) {
    
    float q = y[i]/x[i];
    sumq += q;
    sumq2 += q*q;
  }
  
  cout << "mean=" << sumq/n << endl;
  cout << "sigma=" << sqrt(sumq2/n - sumq*sumq/n/n) << endl;
}







int main()
{
  float x[] = { 0.62, 1.25, 1.91, 3.01, 4.22, 
                5.89, 6.12, 6.86, 8.07, 9.43 };
  float y[] = { 0.572, 0.663, 1.32, 1.79, 2.71, 
                3.52, 3.49, 4, 4.84, 5.58 };
  
  analysis_module* mod[2];
  mod[0] = new print_module;
  mod[1] = new mean_rms_module;
  
  for (int i=0; i<2; i++) {
        mod[i]->process(x,y,10);
  }
  
}