-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGradingStudents.cpp
53 lines (39 loc) · 1.05 KB
/
GradingStudents.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 <bits/stdc++.h>
using namespace std;
/*
* Complete the gradingStudents function below.
*/
vector<int> gradingStudents(vector<int> grades) {
for(int i = 0; i < grades.size(); ++i) {
if(grades[i] < 38) continue;
int modGrade = grades[i]%5;
if(modGrade >= 3) {
grades[i] += 5 - modGrade;
}
}
return grades;
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int n;
cin >> n;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
vector<int> grades(n);
for (int grades_itr = 0; grades_itr < n; grades_itr++) {
int grades_item;
cin >> grades_item;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
grades[grades_itr] = grades_item;
}
vector<int> result = gradingStudents(grades);
for (int result_itr = 0; result_itr < result.size(); result_itr++) {
fout << result[result_itr];
if (result_itr != result.size() - 1) {
fout << "\n";
}
}
fout << "\n";
fout.close();
return 0;
}