可乐爽 @ 2020-07-03 18:13:15
#include<bits/stdc++.h>
using namespace std;
const int maxn=10000000;
struct stu{
int num;
int yw,sx,yy;
int sum;
};
struct stu a[maxn],tmp;
int n,l;
int main() {
cin>>n;
for(int i=1;i<=n;i++) {
cin>>a[i].yw>>a[i].sx>>a[i].yy;
a[i].num=i;
a[i].sum=a[i].yw+a[i].sx+a[i].yy;
}
for(int i=1;i<=n-1;i++){
for(int j=1;j<=n-i;i++){
if((a[j].sum>a[j+1].sum)
||(a[j].sum==a[j+1].sum && a[j].yw>a[j+1].yw)
||(a[j].sum==a[j+1].sum && a[j].yw==a[j+1].yw && a[j].num<a[j+1].num)){
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
}
for(int i=1;i<=5;i++) {
cout<<a[n-i+1].num<<" "<<a[n-i+1].sum<<endl;
}
return 0;
}
#
by SmokedFish @ 2020-07-03 18:15:20
这马蜂(
by Zachary_Cloud @ 2020-07-03 18:34:53
我P党看不懂怎么办
by HearTheWindSing @ 2020-07-03 19:14:20
@可乐爽 用sort吧,这年头已经没多少人手写排序了(滑稽
by 老子是北瓜 @ 2020-07-03 19:41:51
@可乐爽
a[j].sum==a[j+1].sum && a[j].yw==a[j+1].yw && a[j].num<a[j+1].num
序号大的在前面,应为a[j].num>a[j+1].num