#include <iostream.h>
#include <conio.h>
#include <vcl.h>
#pragma hdrstop
//#include <math.hpp>

long double HarmonicMean(const double *Data,
                         const int Data_Size);
int main()
{
  double d[] = {1, 2, 3.9, 4.9, 5, 6, 7};
/*  long double x = Mean(d, 6);
  cout << "x= " << x << endl;
  long double y = Mean(d, (sizeof(d) / sizeof(d[0])) - 1);
  cout << "y= " << y << endl;
  long double z = Mean(d, ARRAYSIZE(d) - 1);
  cout << "z= " << z << endl;
*/
  long double HM = HarmonicMean(d, ARRAYSIZE(d) - 1);
  cout << "Srednia harmoniczna= " << HM << endl;

  getch();
  return 0;
}
//---------------------------------------------------------
long double HarmonicMean(const double *Data,
                         const int Data_Size)
{
  long double sum = 0, HM;
  for (int i=0; i<= Data_Size; i++)
    {
      if (Data[i] > 0)
        sum += 1.0/Data[i];
    };
  if (sum != 0)
    HM = (Data_Size+1.0)/sum;
    else
      cout << "Niedozwolone parametry funkcji" << endl;
  return HM;
}


