#include <stdio.h>
#include <stdlib.h>
typedef struct Grade {
char Name[11];
char ID[11];
char Gender;
int grade;
}Grade;
int main()
{
int n,i,FemaleMax=-1,MaleMin=101,FNum,MNum;
scanf("%d", &n);
Grade *data = (Grade*)malloc(sizeof(Grade)*n);
for (i = 0; i < n; i++) {
scanf("%s %c %s %d", &data[i].Name, &data[i].Gender, &data[i].ID, &data[i].grade);
if (data[i].Gender == 'F'&&data[i].grade>FemaleMax) {
FemaleMax = data[i].grade;
FNum = i;
}
if (data[i].Gender == 'M'&&data[i].grade < MaleMin) {
MaleMin = data[i].grade;
MNum = i;
}
}
if (FemaleMax != -1 && MaleMin != 101) {
printf("%s %s\n", data[FNum].Name, data[FNum].ID);
printf("%s %s\n", data[MNum].Name, data[MNum].ID);
printf("%d\n", data[FNum].grade- data[MNum].grade);
}
else {
if (FemaleMax == -1)
printf("Absent\n");
else printf("%s %s\n", data[FNum].Name, data[FNum].ID);
if(MaleMin==101)
printf("Absent\n");
else printf("%s %s\n", data[MNum].Name, data[MNum].ID);
printf("NA\n");
}
free(data);
return 0;
}
1036. Boys vs Girls
最新推荐文章于 2024-02-18 10:54:43 发布