AndyPomeloMars @ 2022-10-15 13:55:42
#include <iostream>
#include <algorithm>
using namespace std;
struct StuSS {int N,C,M,E,T;};
bool StuSSCMP(StuSS A,StuSS B){
if (A.T>B.T) return A.T>B.T;
else if (A.T==B.T){
if (A.C>B.C) return A.T>B.T;
else return A.N<B.N;
}
else return A.T>B.T;
}
int main(){
int N;
cin >> N;
StuSS stuss[N];
for (int i=0;i<N;i++){
stuss[i].N = i+1;
cin >> stuss[i].C >> stuss[i].M >> stuss[i].E;
stuss[i].T = stuss[i].C + stuss[i].M + stuss[i].E;
}
sort(stuss, stuss+N, StuSSCMP);
for (int i=0;i<5;i++) cout << stuss[i].N << ' ' << stuss[i].T << endl;
}
by zjy_747287 @ 2022-10-28 23:59:21
@AndyPomeloMars 换种思路看看,自己写排序(比如冒泡),别用快排,自己写操作容易一点,这个我都不知道怎么找错
by __erinww @ 2022-11-14 08:42:57
可以试着用一下stable_sort函数来排序
by __erinww @ 2023-02-25 12:49:30
@__erinww 钓鱼((