-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathA1083.cpp
More file actions
35 lines (32 loc) · 689 Bytes
/
Copy pathA1083.cpp
File metadata and controls
35 lines (32 loc) · 689 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
#include <iostream>
#include <algorithm>
#define MAXN 55
using namespace std;
struct Student{
char name[15], id[15];
int grade;
} stu[MAXN];
bool cmp(Student a, Student b)
{
return a.grade > b.grade;
}
int main()
{
int n, l, r;
cin >> n;
for (int i = 0; i < n; i++)
scanf("%s %s %d", stu[i].name, stu[i].id, &stu[i].grade);
sort(stu, stu + n, cmp);
cin >> l >> r;
bool hasOutput = false;
for (int i = 0; i < n; i++)
{
if (l <= stu[i].grade && stu[i].grade <= r)
{
hasOutput = true;
printf("%s %s\n", stu[i].name, stu[i].id);
}
}
if (!hasOutput) printf("NONE\n");
return 0;
}