全WA求助

P5726 【深基4.习9】打分

isJason @ 2022-07-18 10:59:52

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, a[1010]; 
    double ans;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a, a+n);
    for(int i=1; i<n-1; i++){
        ans+=a[i];
    }
    cout<<ans/(n-2);
    return 0;
}

by SmallBlack @ 2022-07-18 11:06:33

需要保留两位小数 把cout<<ans/(n-2);改成printf("%.2lf\n",ans/(n-2));


by isJason @ 2022-07-18 11:53:31

啊,谢谢,莫名其妙的错误+1


|