第三个点是什么。我怎么不对

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

neu_greg_hu @ 2020-04-30 11:48:16

5555


by Cult_style @ 2020-04-30 11:48:37

代码放上来


by Cult_style @ 2020-04-30 11:48:55

@neu_greg_hu


by zadji @ 2020-08-16 08:46:54

#include <bits/stdc++.h>
using namespace std;
struct student{
    string name;
    int a,b,c,id,score; 
};
student x[1005];
int n;
bool cmp(const student&a,const student&b){
    if(a.score==b.score){
        return a.id<b.id;
    } 
    return a.score>b.score; 
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i].name>>x[i].a>>x[i].b>>x[i].c;
        x[i].id=i;
        x[i].score=x[i].a+x[i].b+x[i].c;
    }
    sort(x,x+n,cmp);
    cout<<x[0].name<<" "<<x[0].a<<" "<<x[0].b<<" "<<x[0].c; 
    return 0;
}

|