physics—LindseyWEI @ 2018-07-28 22:20:39
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
int n;
struct node{
int chi;
int math;
int e;
int sum;
int num;
}a[305];
bool cmp(node x,node y)
{
if(x.sum!=y.sum)
{
return x.sum>y.sum;
}
else if(x.chi!=y.chi)
{
return x.chi>y.chi;
}
else
{
return x.num>y.num;
}
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].chi>>a[i].math>>a[i].e;
a[i].sum=a[i].chi+a[i].math+a[i].e;
a[i].num=i;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++)
{
cout<<a[i].num<<" "<<a[i].sum<<endl;
}
return 0;
}
by dyyzy @ 2022-07-19 14:15:44
return x.num>y.num;
应改成
return x.num<y.num;