80 分求助,测试点 5 和 10 过不了

B2095 白细胞计数

sm11e @ 2023-10-20 00:36:20


#include <stdio.h>

#include <math.h>

int main ()

{

    int n ;

    double a=0,b,sum=0,psum=0,arr[301],brr[301];

    scanf("%d",&n);

    for (int i =0;i<n;i++)

    {

        scanf("%lf",&arr[i]);

        sum+=arr[i];

    }

    for (int j =0;j<n;j++)

    {

        if (arr[j]>=a) a=arr[j];

    }

    b=a;

    for (int u =0;u<n;u++)

    {

        if (arr[u]<b) b=arr[u];

        else continue;

    }

    sum=sum-a-b;

    psum=sum/(n-2);

    for (int k =0;k<n;k++)

    {

    brr[k]=fabs(arr[k]-psum);       

    }

    for (int g =0;g<n;g++)

    {

        if(brr[g]==fabs(a-psum)) 

        {

        brr[g]=brr[g-1];

        break;

        }

        else continue;

    }

    double d =0;

    for (int f=0;f<n;f++)

    {

        if(brr[f]==(psum-b)) continue;

        else 

        {

        if (brr[f]>=d) d=brr[f];

        }

    }

        printf("%.2lf %.2lf",psum,d);

    return 0;

}

|