Doctor_zhc @ 2022-01-29 09:06:30
#include<bits/stdc++.h>
using namespace std;
int n;
struct node{
int value,ch,next;
};
node a[301];
bool cmp(node a,node b){
if(a.value>b.value)
return true;
if(a.value==b.value){
if(a.ch>b.ch)
return true;
else if(a.ch==a.ch){
if(a.next<=b.next)
return true;
else
return false;
}
else
return false;
}
else
return false;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
int che,b,c;
scanf("%d%d%d",&che,&b,&c);
a[i].value=che+b+c;
a[i].ch=che;
a[i].next=i;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++)
printf("%d %d\n",a[i].next,a[i].value);
return 0;
}
by tthhrr123 @ 2022-01-29 14:19:40
哪道题
by mmolmmol @ 2022-01-29 18:55:42
cmp函数在判断a和b的语文分相等时出错了,你写了个a.ch==a.ch,你这个写错了,应该是手抖了一下。另外有一些地方你可以注意一下:
by mmolmmol @ 2022-01-29 18:58:42
@Doctor_zhc
by Doctor_zhc @ 2022-01-30 08:37:43
多谢大佬!