a___ @ 2017-03-14 22:15:52
#include <iostream>
#include <algorithm>
using namespace std;
struct student {
int tt,yf,zf;
};
bool comp (student a,student b)
{
return a.zf>b.zf;
return a.yf>b.yf;
return a.tt<b.tt;
}
int main()
{
int n,i,sf,yyf;
cin>>n;
student a[n];
for (i=0;i<n;i++)
{
cin>>a[i].yf>>sf>>yyf;
a[i].zf=a[i].yf+sf+yyf;
a[i].tt=i+1;
}
sort (a,a+n,comp);
for (i=0;i<5;i++) cout<<a[i].tt<<' '<<a[i].zf<<endl;
return 0;
}
by 天下第一剑客 @ 2017-04-11 23:05:49
你的comp函数错了,应该是
bool cmp(Grade a, Grade b){return a.tot>b.tot || (a.tot==b.tot && (a.literature>b.literature || (a.literature==b.literature && a.num<b.num)));} (我的变量名顾名思义就不解释了)