297,455 views
30 votes
30 votes
Subtract 4 from any element's value that is greater than maxval. Ex: if maxval = 10, then datapoints = {2, 12, 9, 20} becomes {2, 8, 9, 16}.

User TrashyMcTrash
by
2.3k points

1 Answer

15 votes
15 votes

Answer:

Explanation:

for (i = 0; i < dataPoints.size(); ++i) {

if (dataPoints.at(i) > maxVal) {

dataPoints.at(i) = dataPoints.at(i) - 4;

}

}

User Friendlygiraffe
by
3.0k points