Dateien nach „BSP_1_A“ hochladen
This commit is contained in:
parent
40e2b29d95
commit
97a7a2432d
4 changed files with 166 additions and 0 deletions
38
BSP_1_A/bsp_1_a.cpp
Normal file
38
BSP_1_A/bsp_1_a.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue