shengsimiao @ 2023-12-30 11:51:49
#include<bits/stdc++.h>
using namespace std;
struct b{
int ch;
int ma;
int en;
int sum;
int id;
}arr[1010];
bool cmp(b a,b c){
if(a.sum != c.sum){
return a.sum>c.sum;
}
return a.id<c.id;
}
int b[1010];
int main(){
int n;
cin >> n;
for(int i=0;i<n;i++){
cin >> arr[i].ch;
cin >> arr[i].ma;
cin >> arr[i].en;
arr[i].sum=arr[i].ch+arr[i].en+arr[i].ma;
arr[i].id=i+1;
}
sort(arr,arr+n+1,cmp);
for(int i=0;i<5;i++){
cout<<arr[i].id<<" "<<arr[i].sum<<endl;
}
return 0;
}
by Wang_Junduo @ 2024-01-22 15:07:30
bool cmp(student a,student b) { if(a.score!=b.score) return a.score>b.score; else if(a.chinese!=b.chinese) return a.chinese>b.chinese; else return a.id<b.id; }
by Wang_Junduo @ 2024-01-22 15:08:29
sort函数不+1
by shengsimiao @ 2024-03-01 17:53:07
@lovec 感谢已关注