没毛病,但是为什么0分?

B2095 白细胞计数

bcm_ahdu @ 2025-01-04 14:33:22

求大佬帮助

#include<bits/stdc++.h>
using namespace std;
int main(){
    double maxx=-10000,minn=10000;
    double d,c[301],b[301],h=0;
    int n,i,v,k;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>c[i];
        h=h+c[i];
        if(c[i]>maxx){
            maxx=c[i];
            k=i;
        }
        if(c[i]<minn){
            minn=c[i];
            v=i;
        }
    }
    d=(h-c[v]-c[k])/(n-2.00);
    printf("%.2lf\n",d);
    for(i=1;i<=n;i++){
        if(i!=k and i!=v)b[i]=abs(d-c[i]);
        else b[i]=-10001;
    }
    maxx=-10001;
    for(i=1;i<=n;i++)
        if(b[i]>maxx)maxx=b[i];
    printf("%.2lf\n",maxx);
    return 0; 
}

by liuhuanjun @ 2025-01-04 16:35:39

c[i]最大为10^9^,maxx和minn的值应为-999999999和999999999,要不就设为MAX_INT


by bcm_ahdu @ 2025-01-04 20:13:34

@liuhuanjunthank you


|