#include<iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student
{
int score ;
int age;
}s[100];
//按照x从小到大排序,当x相等时按照y从大到小排序
void main()
{
student A,B,C,D,E;
A.score=100;
B.score=93;
C.score=98;
D.score=95;
E.score=96;
A.age=20;
B.age=23;
C.age=19;
D.age=21;
E.age=22;
qsort(s,100,sizeof(s[0]),cmp);
}
int cmp( const void *a , const void *b )
{
struct student *c=(student*)a;
struct student *d = (student*)b;
if(c->score != d->score) return c->score - d->score;
else return d->age - c->age;
}