LIUZHIYU1 @ 2023-03-13 20:45:36
#include<iostream>
#include<iomanip>
using namespace std;
int a,b;
double c=0;
int main(){
cin>>a;
for(int i=0;i<a;i++){
cin>>b;
c+=b/(double)a;
}
cout<<fixed<<setprecision(2)<<c;
}
开double
了怎么精度还是不够
by Sun_Email @ 2023-03-13 20:49:01
建议直接求和,然后拿和
by CSP_AK_zc @ 2023-03-13 20:50:08
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
double ans=0.0;
long long n,age,i;
cin>>n;
for(i=1; i<=n; i++) {
cin>>age;
ans+=age;
}
ans=ans/n;
printf("%.2f",ans);
}
供参考
抄袭
by CSP_AK_zc @ 2023-03-13 20:50:56
@LIUZHIYU1 此外,恭喜绿名
by LIUZHIYU1 @ 2023-03-13 20:52:10
@todd6222 谢谢鼓励!
by __er @ 2023-03-13 20:57:31
@LIUZHIYU1 一边加一边除精度掉飞了,有点常识,除法掉精度、、、
by Hihukeke @ 2023-04-15 17:25:04
jkfjjskajld;fjierfjjkdjfjdsfkrjhirkljjgrgklggfkgfjglkjljlsdlk lkj;ljlkjkl joirkforf9rj krl kjklj kjj ;lkjgjkjro'kgrjlgkjfgkgkjgirhgjgrirhggn;dfglkkdlgjlksj;jkfk;gjoijirgrngkll \
by LIUZHIYU1 @ 2023-05-28 09:49:34
@Hihukeke ? 不要刷屏