编译失败,帮忙找一下bug

B2095 白细胞计数

aishiteru_mitsu_ha @ 2023-12-19 18:27:52

#include<bits/stdc++.h>
using namespace std;
int maxx=-100000000,minn=1000000000;
int main(){
    vector<int> b;
    long long n,a[1000],ans=0;
    double sb;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>sb;
        maxx=max(maxx,sb);
        minn=min(minn,sb);
        ans+=sb;
        b.push_back(sb);
    }
    ans=1.0*(ans-maxx-minn)/(n-2);
    for(int i=1;i<=n;i++){
        a[i]=pow(b[i-1]-ans);
    }
    sort(a+1,a+n);
    cout<<fixed<<setprecision(2)<<ans<<" "<<a[n];
    return 0;
}

by Shadow_T @ 2023-12-19 18:29:25

@not_much max,min的问题


by Shadow_T @ 2023-12-19 18:30:00

把 max 改成 a>b?a:b

min 改 a<b?a:b


by penguin_is_cool @ 2023-12-19 18:31:16

@not_much 十八行,你是几次方?


by derekyang326 @ 2023-12-19 18:33:08

max,min(自带)只能处理int,你可以自己编max&min


by Lyz09 @ 2023-12-19 18:47:07

@derekyang326 什么类型的都可以,前提是两者类型相同且定义了比较大小的函数


by zj13516757538 @ 2024-01-01 20:32:11

你自己看看``` maxx=max(maxx,sb);


|