-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathA1036.cpp
62 lines (58 loc) · 1.19 KB
/
A1036.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <cstdio>
#include <cstring>
#include <cstdlib>
//using namespace std;
struct Student{
char name[16];
char gender[4];
char id[16];
int score;
Student() : score(0){}
Student(int s) : score(s){}
bool operator < (const Student &s) const{
return score < s.score;
}
bool operator > (const Student &s) const{
return score > s.score;
}
/**Student &operator = (const Student &s){
strcpy(name, s.name);
strcpy(gender, s.gender);
strcpy(id, s.id);
score = s.score;
return *this;
}**/
};
int main(){
int n;
scanf("%d", &n);
Student tmp, lowest_male(101), highest_female(-1);
bool flag1 = false, flag2 = false;
while(n--){
scanf("%s%s%s%d", tmp.name, tmp.gender, tmp.id, &tmp.score);
if(tmp.gender[0] == 'M'){
flag1 = true;
if(tmp < lowest_male){
lowest_male = tmp;
}
}else{
flag2 = true;
if(tmp > highest_female){
highest_female = tmp;
}
}
}
if(flag2)
printf("%s %s\n", highest_female.name, highest_female.id);
else
printf("Absent\n");
if(flag1)
printf("%s %s\n", lowest_male.name, lowest_male.id);
else
printf("Absent\n");
if(flag1 && flag2)
printf("%d", abs(highest_female.score - lowest_male.score));
else
printf("NA");
return 0;
}