-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoys_vs_Girls.cpp
53 lines (51 loc) · 1.02 KB
/
Boys_vs_Girls.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
#include <iostream>
#include <string>
int main()
{
int n;
std::cin >> n;
std::string name, id, mname, mid, fname, fid;
int mgrade = 101, fgrade = -1, grade;
for (int i = 0; i < n; i++)
{
std::string sex;
std::cin >> name >> sex >> id >> grade;
if (sex == "M" && grade < mgrade)
{
mname = name;
mid = id;
mgrade = grade;
}
else if (sex == "F" && grade > fgrade)
{
fname = name;
fid = id;
fgrade = grade;
}
}
if(fgrade==-1)
{
std::cout << "Absent" << std::endl;
}
else
{
std::cout << fname << " " << fid << std::endl;
}
if(mgrade==101)
{
std::cout << "Absent" << std::endl;
}
else
{
std::cout << mname << " " << mid << std::endl;
}
if(fgrade!=-1&&mgrade!=101)
{
std::cout << fgrade - mgrade<<std::endl;
}
else
{
std::cout << "NA" << std::endl;
}
return 0;
}