chenxianping @ 2024-10-22 22:18:23
不知道哪里错了??????????????
#include<bits/stdc++.h>
using namespace std;
int n;
struct node{
int x,y,z;
int sum;
int v;
}a[310];
bool cmp(node n1,node n2){
if(n1.sum==n2.sum){
if(n1.x==n2.x){
return n1.v<n2.v;
}else{
return n1.x>n2.x;
}
}else{
return n1.sum>n2.sum;
}
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d &d %d",&a[i].x,&a[i].y,&a[i].z);
a[i].v=i;
a[i].sum=a[i].x+a[i].y+a[i].z;
}
sort(a+1,a+1+n,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].v<<" "<<a[i].sum<<endl;
}
return 0;
}
by ZR_HY_XS @ 2024-10-24 19:33:28
函数顺序错误