//
// main.cpp
// PATA1036
//
// Created by Phoenix on 2018/2/10.
// Copyright © 2018年 Phoenix. All rights reserved.
//
#include <iostream>
#include <cstdio>
#include <cstring>
int main(int argc, const char * argv[]) {
int n;
scanf("%d", &n);
char m_name[15], m_id[15], f_name[15], f_id[15], gender;
int m_grade = 101, f_grade = -1;
for(int i = 0; i < n; i++) {
char name[15], id[15];
int grade;
scanf("%s %c %s %d", name, &gender, id, &grade);
if(gender == 'F' && grade > f_grade) {
f_grade = grade;
strcpy(f_name, name);
strcpy(f_id, id);
}
if(gender == 'M' && grade < m_grade) {
m_grade = grade;
strcpy(m_name, name);
strcpy(m_id, id);
}
}
bool flag = true;
if(f_grade > -1) {
printf("%s %s\n", f_name, f_id);
} else {
printf("Absent\n");
flag = false;
}
if(m_grade < 101) {
printf("%s %s\n", m_name, m_id);
} else {
printf("Absent\n");
flag = false;
}
if(flag == true) {
printf("%d", f_grade - m_grade);
}else {
printf("NA");
}
return 0;
}
PATA1036题解
最新推荐文章于 2021-02-02 21:26:13 发布