A1036

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;

int main()
{
    char name[12],id[12],n[2][12],i[2][12];
    char gender;
    int grade,lowest=101,highest=-1;
    int N;
    scanf("%d",&N);
    while(N--){
        scanf("%s %c %s %d",name,&gender,id,&grade);
        if(gender=='F' && highest<grade){
            strcpy(n[0],name);
            strcpy(i[0],id);
            highest=grade;
        }
        if(gender=='M' && lowest>grade){
            strcpy(n[1],name);
            strcpy(i[1],id);
            lowest=grade;
        }
    }
    if(highest==-1) printf("Absent\n");
    else printf("%s %s\n",n[0],i[0]);
    if(lowest==101) printf("Absent\n");
    else printf("%s %s\n",n[1],i[1]);
    if(highest==-1 || lowest==101) printf("NA\n");
    else printf("%d\n",highest-lowest);
    return 0;
}
 

猜你喜欢

转载自blog.csdn.net/fengwuyaQAQ/article/details/86067012