P5740 90分求助!!玄关QAQ

P5740 【深基7.例9】最厉害的学生

yuan_qiu @ 2024-10-21 13:34:55

思路为用for来统一最大值的下标来判断最大 以下为代码!!:

#include<bits/stdc++.h>
using namespace std;
int n,a[1001],b[1001],c[1001],maxx[1001],summ;
string name[1001];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>name[i]>>a[i]>>b[i]>>c[i];
        maxx[i]=a[i]+b[i]+c[i];
        if(maxx[i]>maxx[summ]){
            summ=i;
            //cout<<"***"<<endl;
        }
        else{
            summ=summ;
            //cout<<"####"<<endl;
        }
    }
    cout<<name[summ]<<" "<<a[summ]<<" "<<b[summ]<<" "<<c[summ];
}

by fulezhegerujile @ 2024-10-21 13:56:48

8-10行有问题


by fulezhegerujile @ 2024-10-21 13:57:46

@fulezhegerujile 看错了


by mnlbnkk @ 2024-10-21 17:01:52

@yuan_qiu 你都把我拉黑了我怎么@你\ 还有,这个屎山代码怎么可能过\ 我们来盘点你犯的七宗罪


|