#include <bits/stdc++.h>
using
namespace
std;
float
ArithmeticMean(
float
A,
float
B)
{
return
(A + B) / 2;
}
float
HarmonicMean(
float
A,
float
B)
{
return
(2 * A * B) / (A + B);
}
void
CheckArithmeticHarmonic(
float
arr[],
float
A,
float
B,
int
N)
{
float
AM = ArithmeticMean(A, B);
float
HM = HarmonicMean(A, B);
unordered_set<
float
> Hash;
for
(
int
i = 0; i < N; i++)
{
Hash.insert(arr[i]);
}
if
(Hash.find(A) != Hash.end()
&& Hash.find(B) != Hash.end()) {
if
(Hash.find(AM) != Hash.end()
&& Hash.find(HM) != Hash.end()) {
cout <<
"GM = "
;
printf
(
"%0.2f"
,
sqrt
(AM * HM));
}
else
{
cout <<
"AM and HM not found"
;
}
}
else
{
cout <<
"Numbers not found"
;
}
}
int
main()
{
float
arr[] = {1.0, 2.0, 2.5, 3.0, 4.0,
4.5, 5.0, 6.0};
int
N =
sizeof
(arr)/
sizeof
(arr[0]);
float
A = 3.0;
float
B = 6.0;
CheckArithmeticHarmonic(arr, A, B, N);
return
0;
}