asked 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}.

asked
User Martonx
by
8.6k 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;

}

}

answered
User JoeF
by
8.0k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.