蒟蒻求助95分!!!

B2054 求平均年龄

chenxinuo @ 2023-07-18 18:16:31

#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    float sum=0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        sum+=x;
    }
    printf("%.2lf",sum/n);
    return 0;
}

by STLvector @ 2023-07-18 18:19:30

float精度不够,用double


by chenxinuo @ 2023-07-18 18:23:29

@STLvector 谢谢dalao 已关注


by ZZZEEE @ 2023-09-26 07:46:12

@STLvector 谢谢大佬


|