私はクラスのプロジェクトに取り組んでいますが、幾何平均の出力に問題があり、常に 1 になり、それは正しくないと確信しています。
これが私のコードです:
#include<iostream>
#include<math.h>
using namespace std;
int main(int argc, char**argv)
{
float i, j, k;
float a, h, g;
cout<<"Enter 3 floating point numbers"<<endl;
cin>>i>>j>>k;
while(i>0 && j>0 && k>0 )
{
a = (i+j+k)/3;
h = 3/((1/i) + (1/j) + (1/k));
g = pow((i*j*k),(1/3));
cout<<"Arithmetic: "<<a<<endl;
cout<<"Harmonic: "<<h<<endl;
cout<<"Geometric: "<<g<<endl;
cout<<"Enter 3 floating point numbers"<<endl;
cin>>i>>j>>k;
}
return(0);
}