#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct student{
char name[101];
int age;
int score;
}student;
int cmp(const void *a,const void *b){
student *c=(student *)a;
student *d=(student *)b;
if(c->score!=d->score) return c->score<d->score?1:-1;
if(c->name!=d->name) return strcmp(c->name,d->name);
return c->age<d->age?-1:1;
}
int main(){
int n;
student a[1000];
while((scanf("%d",&n))!=EOF){
getchar();
for(int i=0;i<n;i++){
scanf("%s %d %d",a[i].name,&a[i].age,&a[i].score);
getchar();
}
qsort(a,n,sizeof(a[0]),cmp);
2020-02-07 17:12:38
出家人 2020-07-11 21:00:33 |
输入字符串要考虑系统自动给的字符串结束标志 ' '