mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-11-12 14:40:46 -05:00
C++: Making the Grade: clean up methods
This commit is contained in:
parent
659cce59ff
commit
8a1efbaf0f
1 changed files with 7 additions and 6 deletions
|
@ -30,7 +30,7 @@ std::vector<int> above_threshold(std::vector<int> student_scores,
|
|||
|
||||
for (auto score : student_scores) {
|
||||
if (score >= threshold)
|
||||
res.push_back(score);
|
||||
res.emplace_back(score);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -55,11 +55,11 @@ student_ranking(std::vector<int> student_scores,
|
|||
std::vector<std::string> student_names) {
|
||||
|
||||
std::vector<std::string> res;
|
||||
int rank = 1;
|
||||
int len = student_scores.size();
|
||||
|
||||
for (int i{0}; i < student_scores.size(); i++, rank++) {
|
||||
res.push_back(std::to_string(rank) + "." + " " + student_names[i] + ": " +
|
||||
std::to_string(student_scores[i]));
|
||||
for (int i{0}; i < len; i++) {
|
||||
res.emplace_back(std::to_string(i + 1) + "." + " " + student_names[i] +
|
||||
": " + std::to_string(student_scores[i]));
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -70,7 +70,8 @@ student_ranking(std::vector<int> student_scores,
|
|||
std::string perfect_score(std::vector<int> student_scores,
|
||||
std::vector<std::string> student_names) {
|
||||
|
||||
for (int i{0}; i < student_scores.size(); i++) {
|
||||
int len = student_scores.size();
|
||||
for (int i{0}; i < len; i++) {
|
||||
if (student_scores[i] == 100) {
|
||||
return student_names[i];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue