#include<cstdio>
#include<malloc.h>
#include<algorithm>
using namespace std;
typedef struct stu {
char name[14];
char number[14];
int score;
}student;
bool cmp(student a,student b){
return a.score>b.score;
}
int main() {
int n;
scanf("%d", &n);
student *arr = (student *)malloc(sizeof(student)*n);
for (int i = 0; i<n; i++) {
scanf("%s %s %d", arr[i].name, arr[i].number, &(arr[i].score));
}
sort(arr,arr+n,cmp);
printf("%s %s",arr[0].name,arr[0].number);
printf("\n%s %s",arr[n-1].name,arr[n-1].number);
return 0;
}
原文地址:https://www.cnblogs.com/hebust/p/9498152.html
时间: 2024-10-09 07:30:28