ZhengYuZhe_13 @ 2023-01-14 14:37:52
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct stu{
int num,yw,sx,yy,sum;
}a[305];
bool cmp(stu a,stu b){
if(a.sum!=b.sum){
return a.sum>a.sum;
}else if(a.yw!=b.yw){
return a.yw>b.yw;
}else{
return a.num<b.num;
}
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].yw>>a[i].sx>>a[i].yy;
a[i].sum=a[i].sx+a[i].yw+a[i].yy;
a[i].num=i;
}
sort(a+1,a+1+n,cmp);
for(int i=5;i>=1;i--){
cout<<a[i].num<<' '<<a[i].sx+a[i].yw+a[i].yy<<endl;
}
return 0;
}
有没有dalao告诉我怎么回事
by 编码落寞 @ 2023-01-14 14:55:03
@Declarations
return a.sum>a.sum;
by 编码落寞 @ 2023-01-14 14:57:51
而且你的输出与排序结果 明显不符合要求