比较基本的结构体题目,之前刷sse刷了很多结构体这种题见怪不怪了,AC代码如下
#include <stdio.h>
#include <stdlib.h>
typedef struct student STU;
struct student{
char name[11];
char id[11];
int grade;
};
int main()
{
int n;
scanf("%d", &n);
STU grp[n];
for(int i = 0; i < n; i++){
scanf("%s %s %d", grp[i].name, grp[i].id, &grp[i].grade);
}
STU max, min;
min = max = grp[0];
for(int i = 0; i < n; i++){
if(grp[i].grade > max.grade){
max = grp[i];
}
if(grp[i].grade < min.grade){
min = grp[i];
}
}
printf("%s %s\n", max.name, max.id);
printf("%s %s\n", min.name, min.id);
return 0;
}