1036

来源:互联网 发布:Java开发dwg批量转jpg 编辑:程序博客网 时间:2024/05/16 10:58
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;


int main(){
int N;
cin >> N;


char lowest_name[15];
char lowest_id[15];
int lowest = 101;


char highest_name[15];
char highest_id[15];
int highest = -1;


for (int i = 0; i < N; i++){
char name[15];
char id[15];
char gen;
int grade;
scanf("%s %c %s %d", name, &gen, id, &grade);
if (gen == 'F' && grade > highest){
strcpy(highest_name, name);
strcpy(highest_id, id);
highest = grade;
}


if (gen == 'M'&&grade < lowest){
strcpy(lowest_name, name);
strcpy(lowest_id, id);
lowest = grade;
}
}


bool flag = false;
if (highest == -1){
printf("Absent\n");
flag = true;
}
else{
printf("%s %s\n", highest_name, highest_id);
}




if (lowest == 101){
printf("Absent\n");
flag = true;
}
else{
printf("%s %s\n", lowest_name, lowest_id);
}


if (flag)
printf("NA\n");
else
printf("%d\n", highest - lowest);


return 0;
}
0 0
原创粉丝点击