压根不会

B2095 白细胞计数

xuyangming @ 2024-07-30 09:12:45

#include<iostream>
using namespace std;
double a[100+5];
int main()
{
    int n,i=0;
    for(i;i<=n;i++)
    {
        cin>>a[i];
    }
    return 0;
}    

by Cczzyy20150005 @ 2024-07-30 09:14:04


by Ahws_rwhy @ 2024-07-30 09:20:19

打擂台即可


by yangduan_ @ 2024-07-30 09:34:46

#include<bits/stdc++.h>
using namespace std;
#define N 1010
#define ll long long
int n;
double a[N],maxx=-1.0,minn=12345678.0,sum,ans;
int main(){
    int i,j;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
        maxx=max(maxx,a[i]);
        minn=min(minn,a[i]);
        sum+=a[i];
    }
    sum-=maxx;
    sum-=minn;
    double pj=sum/(n-2)*1.0;
    printf("%.2lf ",pj);
    for(i=1;i<=n;i++){
        if(a[i]==maxx){
            a[i]=-1;
            break;
        }
    }
    for(i=1;i<=n;i++){
        if(a[i]==minn){
            a[i]=-1;
            break;
        }
    }
    for(i=1;i<=n;i++){
        if(a[i]>=0){
            ans=max(fabs(a[i]-pj),ans);
        }
    }
    printf("%.2lf",ans);
    return 0;
}

@xuyangming


by NullPointerExpection @ 2024-07-30 09:34:58

模拟即可


by jiangjun12345 @ 2024-07-31 11:36:47

#include<bits/stdc++.h>
using namespace std;
int main(){
    double a[301],max,min,n,s=0,max1=0,id1,id2;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    max=min=a[0];
    for(int i=0;i<n;i++){
        s=s+a[i];
        if(a[i]>max){
            max=a[i];
            id1=i;
        }
        if(a[i]<min){
            min=a[i];
            id2=i;
        }
    }
    s=(s-max-min)/(n-2);
    for(int i=0;i<n;i++){
        if(i!=id1&&i!=id2){
            double x=fabs(s-a[i]);
            if(x>max1){
                max1=x;
            }
        }
    }
    cout<<fixed<<setprecision(2)<<s<<" "<<max1;
    return 0;
}

|