q求救q

P1093 [NOIP2007 普及组] 奖学金

ltllqy @ 2024-10-27 09:48:51

#include <bits/stdc++.h>
using namespace std;
struct student{
    int xh,c,m,e;
};
bool cmp(student a;student b){
    if(a.sum>b.sum) return 1;
    if(a.sum==b.sum){
        if(a.c>b.c) return 1;
        if(a.c==b.c){
            if(a.xh<b.xh) return 1;
        }
    }
    return 0;
}
student a[310];
int main(){
    int n;
    cin>>n;
    for(int i+1;i<=n;i++){
        cin>>a[i].c>>a[i].m>>a[i].e;
        a[i].xh=i;
        a[i].sum=a[i].c+a[i].m+a[i].e;  
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=5;i++){
        cout<<a[i].xh<<" ">>a[i].s<endl;
    }
    retun 0;
}

|