38 lines
810 B
C++
38 lines
810 B
C++
#include "bsp_1_a.h"
|
|
#include<cmath>
|
|
|
|
using namespace std;
|
|
|
|
void mean(long long int x, long long int y, long long int z, float &a, float &g, float &h)
|
|
{
|
|
a = x/3.0 + y/3.0 + z/3.0; // arithmetisches Mittel
|
|
g = pow(x,1/3.0)*pow(y,1/3.0)*pow(z,1/3.0); // geometrisches Mittel
|
|
h = 3/((1.0/x)+(1.0/y)+(1.0/z)); // harmonisches Mittel
|
|
return;
|
|
}
|
|
|
|
|
|
void meanvec(std::vector<float> x, float &a, float &g, float &h)
|
|
{
|
|
a = 0;
|
|
for(size_t k=1; k<=x.size(); k=k+1)
|
|
{
|
|
a = a+x.at(k-1);
|
|
}
|
|
a = a/x.size();
|
|
|
|
g = 1;
|
|
for(size_t k=1; k<=x.size(); k=k+1)
|
|
{
|
|
g = g*pow(x.at(k-1),1.0/x.size());
|
|
}
|
|
|
|
h = 0;
|
|
for(size_t k=1; k<=x.size(); k=k+1)
|
|
{
|
|
h = h + 1.0/x.at(k-1);
|
|
}
|
|
h = x.size()/h;
|
|
|
|
return;
|
|
}
|