我正在尝试制作一个计算几何平均值的程序。但是我得到了这个错误消息:左值作为赋值的左操作数
#include<stdio.h>
#include<conio.h>
int main() {
float number1,number2,avarage;
printf("enter the numbers which you want to calculate geometrical average of them > ");
scanf("%f %f",&number1,&number2);
average*average=number1*number1+number2*number2;
printf("Geometrical avarage is:%f",sayi);
getch();
return 0;
}
(我尝试了#34; ==&#34;也是运营商,但在这段时间分配给0.00平均值)
由于
答案 0 :(得分:1)
这是一个数学问题,而不是编程问题。 如果你知道
average*average = number1*number1+number2*number2
你必须首先评估平均值。解决方案是
average = sqrt(number1*number1+number2*number2)
EDIT1: 但几何平均值应计算为
average = sqrt(number1 * number2)
答案 1 :(得分:1)
使用此公式计算几何平均值:
Geometric average = square root of (number1 * number2)
#include<stdio.h>
#include<math.h>
int main()
{
float number1,number2,average;
printf("enter the numbers which you want to calculate geometrical average of them > ");
scanf("%f %f",&number1,&number2);
average=sqrt(number1*number2);
printf("Geometrical average is:%f",average);
return 0;
}