-
Notifications
You must be signed in to change notification settings - Fork 0
/
table.cpp
22 lines (17 loc) · 842 Bytes
/
table.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <vector>
#include <algorithm>
#include <cmath>
#include "student.h"
bool compareStudentsForScholarship(const Student &first, const Student &second);
std::vector<Student> getScholarshipReceivers(const std::vector<Student> &students) {
std::vector<Student> receivers(students);
std::sort(receivers.begin(), receivers.end(), compareStudentsForScholarship);
int scholarshipCapacity = (int) std::round(receivers.size() * 0.4);
return std::vector<Student>(receivers.begin(), receivers.begin() + scholarshipCapacity);
}
bool compareStudentsForScholarship(const Student &first, const Student &second) {
return first.getAverageGrade() > second.getAverageGrade();
}
double getMinimumAvgGradeForScholarship(const std::vector<Student> &scholarshipReceivers) {
return scholarshipReceivers.back().getAverageGrade();
}