基础实验7-2.3 德才论 (25 分)
结构体排序
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
struct p{
int a,b,c,f1,f2,f3;
string s;
}t[101000];
bool cmp(p x,p y){
if(x.f1>y.f1)
return 1;
else if(x.f1==y.f1){
if(x.f2>y.f2)
return 1;
else if(x.f2==y.f2){
if(x.f3>y.f3)
return 1;
else if(x.f3==y.f3){
if(x.c>y.c)
return 1;
else if(x.c==y.c)
{
if(x.a>y.a)
return 1;
else if(x.a==y.a)
return x.s<y.s;
}
}
}
}
return 0;
}
int main()
{
int n,l,h,ret=0;
cin>>n>>l>>h;
while(n--)
{
string s1;
int x,y;
cin>>s1>>x>>y;
if(x>=l&&y>=l){
t[ret].s=s1;
t[ret].a=x;
t[ret].b=y;
t[ret].c=x+y;
if(x>=h&&y>=h)
t[ret].f1=1;
else if(x>=h)
t[ret].f2=1;
else if(x>=y)
t[ret].f3=1;
ret++;
}
}
sort(t,t+ret,cmp);
cout<<ret<<endl;
for(int i=0;i<ret;++i)
cout<<t[i].s<<" "<<t[i].a<<" "<<t[i].b<<endl;
}