int main() {
int num = 5;
float sum = 0, height;
for (int i = 0; i < num; i++) {
scanf("%f", &height);
sum += height;
}
printf("%.2f", sum/num);
return 0;
}
#include <stdio.h>
int main()
{
const int num = 5;//总人数
float height = 0.0f;
float sum = 0.0f;
float age = 0.0f;
int i = 0;
for(i = 0; i < num; i++)
{
scanf("%f", &height);
sum += height;
}
age = sum / num;
printf("%.2f\n", age);
return 0;
}
//BC72 平均身高
#include<stdio.h>
int main()
{
int i = 0;
int n = 5;
float sum = 0;
float arr[10] = { 0 };
//录入n个数至数组,并累加
for (i = 0; i < n; i++)
{
scanf("%f", &arr[i]);
sum += arr[i];
}
printf("%.2f ", sum / n);
return 0;
}