Oscar A.

asked • 04/17/20

Write a loop that subtracts 1 from each element in lowerScores if the original element was greater than 0, and otherwise just assigns the element with 0.

Write a loop that subtracts 1 from each element in lowerScores if the original element was greater than 0, and otherwise just assigns the element with 0. Ex: lowerScores = {5, 0, 2, -3} becomes {4, 0, 1, 0}.


#include <iostream>

#include <vector>

using namespace std;


int main() {

const int SCORES_SIZE = 4;

vector<int> lowerScores(SCORES_SIZE);

unsigned int i;


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

cin >> lowerScores.at(i);

}


/* Your solution goes here */


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

cout << lowerScores.at(i) << " ";

}

cout << endl;


return 0;

}

1 Expert Answer

By:

Patrick B. answered • 04/17/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.