sbjzh @ 2022-07-02 10:58:21
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct cj{
int id,zf,yu,shu,ying;
}a[101];
bool mycmp(cj a,cj b)
{
return a.zf>b.zf||a.zf==b.zf&&a.yu<b.yu||a.zf==b.zf&&a.yu==b.yu&&a.id<b.id;
}
int n;
int main()
{
cin>>n;
for(int i=1;i<=n;i++){
a[i].id=i;
cin>>a[i].yu>>a[i].shu>>a[i].ying;
a[i].zf=a[i].yu+a[i].shu+a[i].ying;
}
sort(a+1,a+n+1,mycmp);
for(int i=1;i<=5;i++)
cout<<a[i].id<<" "<<a[i].zf<<endl;
return 0;
}
by Hisaishi_Kanade @ 2022-07-02 11:00:31
@wangshaoju66 mycmp在干嘛啊,三目运算符不能用吗
by sbjzh @ 2022-07-02 11:05:58
三目运算符是啥玩意儿??!
by ningago @ 2022-07-02 11:14:19
@wangshaoju66
@wangshaoju66
压缩if用的
if(aya)
kkk = aya_cute;
else
kkk = chtholly_forever;
等价于
kkk = aya ? aya_cute : chtholly_forever;