-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA1036.cpp
More file actions
44 lines (42 loc) · 934 Bytes
/
A1036.cpp
File metadata and controls
44 lines (42 loc) · 934 Bytes
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
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
struct student{
string name,ID;
char gender;
int grade;
};
int main() {
int n,tm=0,tf=0;
student min,max;
min.grade=100;
max.grade=0;
cin>>n;
student *stu=new student[n];
for (int i=0; i<n; i++) {
cin>>stu[i].name>>stu[i].gender>>stu[i].ID>>stu[i].grade;
if (stu[i].gender=='M') {
tm=1;
if (min.grade>stu[i].grade) {
min=stu[i];
}
}
else {
tf=1;
if (max.grade<stu[i].grade) {
max=stu[i];
}
}
}
if (tf==0)
cout<<"Absent"<<endl;
else cout<<max.name<<" "<<max.ID<<endl;
if (tm==0)
cout<<"Absent"<<endl;
else cout<<min.name<<" "<<min.ID<<endl;
if(tm==0||tf==0)
cout<<"NA";
else cout<<max.grade-min.grade;
return 0;
}