chenruiming @ 2024-07-16 15:13:43
by YCN_AK_NOI @ 2024-07-16 15:15:02
@chenruiming 代码呢
by fire_flies @ 2024-07-16 15:15:57
@chenruiming 这题直接相加然后除以人数就行,要用浮点型```
#include<iostream>
using namespace std;
int main()
{
int n,i,l;
double s=0;
cin>>n;
for(i=1;i<=n;i++){
cin>>l;
s=s+l;
}
printf("%0.2f",s/n);
}
by fire_flies @ 2024-07-16 15:17:14
@chenruiming 你源码中的h要用double或float 求关谢谢
by Enoch2013 @ 2024-07-16 15:18:50
@chenruiming ac code:
#include <cstdio>
using namespace std;
int main()
{
int n;
double s = 0.0;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
int a;
scanf("%d", &a);
s += a;
}
printf("%.2lf\n", s / n);
return 0;
}
求关注,qwq
by 枫原万叶 @ 2024-07-16 15:32:56
小学知识,总数/人数=平均值
#include <bits/stdc++.h>
using namespace std;
int main() {
double n, k, b = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> k;
b += k;
}
printf("%.2lf", b / n) ;
return 0;
}