题解:本题主要考查排序(简单),我就用刚学的结构体排序来做。
代码如下:
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int n,i,cmax=0,num;
struct s
{
int c,m,e,total,num;
};s a[301];
bool com(s a,s b)
{
if(a.total!=b.total)
return a.total>b.total;
else
if(a.c!=b.c)
return a.c>b.c;
else
return a.num<b.num;
}
int main()
{
cin>>n;
for(i=1;i<=n;i++)
{
a[i].num=i;
cin>>a[i].c>>a[i].m>>a[i].e;
a[i].total=a[i].c+a[i].m+a[i].e;
}
stable_sort(a+1,a+n+1,com);
for(i=1;i<=5;i++)
{
cout<<a[i].num<<" "<<a[i].total<<endl;
}
return 0;
}