104k views
5 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 Martonx
by
3.7k points

1 Answer

4 votes

Answer:

Explanation:

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

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

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

}

}

User JoeF
by
3.1k points