#include<stdio.h>
#include<stdlib.h>
struct student{
int num;
int de;
int cai;
int sum;
};
int cmp(const void *a,const void *b){
struct student *s,*t;
s=(struct student *)a;
t=(struct student *)b;
int fs,ft;
fs=s->de +s->cai ;
ft=t->de +t->cai ;
if(fs!=ft)
return ft-fs;
else if(fs==ft)//总相同 德降序
return (t->de )-(s->de );
else//德相同 号升序
return (s->num )-(t->num );
}
void print(struct student a[],int n){
for(int i=0;i<n;i++){
printf("%d %d %d\n",a[i].num,a[i].de,a[i].cai);
}
}
int main(){
int n,l,h;
int i1=0,i2=0,i3=0,i4=0;
// int print(int a[],int n);
scanf("%d %d %d",&n,&l,&h);
struct student st;
struct student st1[n],st2[n],st3[n],st4[n];
for(int j=0;j<n;j++){
scanf("%d %d %d",&st.num ,&st.de ,&st.cai );
if(st.de >=l&&st.cai >=l){
if(st.de>=h&&st.cai >=h){
st1[i1++]=st;
/*if(st[i].de >=h&&st[i].cai >=h){
st1[i1].de =st[i].de ;
st1[i1].cai =st[i].cai ;
st1[i1].sum =st[i].de +st[i].cai ;
i1++;*/
}
else if(st.de >=h){
st2[i2++]=st;
/*st2[i2].de =st[i].de ;
st2[i2].cai =st[i].cai ;
st2[i2].sum =st[i].de +st[i].cai ;
i2++;*/
}
else if(st.de >=st.cai ){
st3[i3++]=st;
/*st3[i3].de =st[i].de ;
st3[i3].cai =st[i].cai ;
st3[i3].sum =st[i].de +st[i].cai ;
i3++;*/
}
else{
st4[i4++]=st;
/* st4[i4].de=st[i].de ;
st4[i4].cai=st[i].cai ;
st4[i4].sum=st[i].cai +st[i].de ;
i4++;*/
}
}
}
qsort(st1,i1,sizeof *st1,cmp);
qsort(st2,i2,sizeof *st2,cmp);
qsort(st3,i3,sizeof *st3,cmp);
qsort(st4,i4,sizeof *st4,cmp);
printf("%d\n",i1+i2+i3+i4);
print(st1,i1);
print(st2,i2);
print(st3,i3);
print(st4,i4);
return 0;
}
不明白哪里有误,在devc++上输入后能得到正确输出 但提交到pta后却显示错误