只得了50分

B2095 白细胞计数

Pearls @ 2024-05-23 17:12:46

#include<bits/stdc++.h>
using namespace std;
double a,n,b[301],s,m=300,c,d;
int main()
{
    cin>>a;
    for(int i=1;i<=a;i++){
        cin>>b[i];
        if(b[i]>n){
            n=b[i];
        }
        if(b[i]<m){
            m=b[i];
        }
        s+=b[i];
    }
    s-=m+n;
    c=m;
    s/=(a-2);
    printf("%.2lf",s);
    cout<<" ";
    m=0;
    for(int i=1;i<=a;i++){
        if(b[i]-s>m&&b[i]!=c&&b[i]!=n){
            m=b[i]-s;
        }
        if(s-b[i]>m&&b[i]!=c&&b[i]!=n){
            m=s-b[i];
        }
    } 
    printf("%.2lf",m);
    return 0;
}

by CCSBZR11_cn @ 2024-05-23 17:43:14

@Pearls

#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >>n;
float a[1298];
for (int i=1;i<=n;i++){
    cin >>a[i];
}
for (int i=1;i<=n;i++){
    for (int j=1;j<=n-i;j++)
        if (a[j]>a[j+1])
        swap(a[j],a[j+1]);
}
float sum=0.00;
for (int i=2;i<n;i++){
    sum+=a[i];
}
printf("%.2lf ",sum/=(n-2));
float b[n];
for (int i=2;i<n;i++){
    b[i]=abs(a[i]-sum);
}
float ma=0.00;
for (int i=1;i<=n;i++){
    if(ma<b[i])
    ma=b[i];
}
printf("%.2lf",ma);
    return 0;                                      
} 

求关注


|