Question
Integer numValues is read from input. Then numValues integers are read and stored in vector scoresList. Write a loop that outputs each element in scoresList
Integer numValues is read from input. Then numValues integers are read and stored in vector scoresList. Write a loop that outputs each element in scoresList that is greater than 200, and assigns the element with 200. End each output with " is adjusted to 200" followed by a newline.
Ex: If the input is 3 216 197 147, then the output is:
Raw scores: 216 197 147
216 is adjusted to 200
Adjusted scores: 200 197 147
Code:
#include
#include
using namespace std;
int main() {
int numValues;
unsigned int i;
vector
cin >> numValues;
scoresList.resize(numValues);
for (i = 0; i < scoresList.size(); ++i) {
cin >> scoresList.at(i);
}
cout << "Raw scores: ";
for (i = 0; i < scoresList.size(); ++i) {
cout << scoresList.at(i) << " ";
}
cout << endl;
/* Your code goes here */
cout << "Adjusted scores: ";
for (i = 0; i < scoresList.size(); ++i) {
cout << scoresList.at(i) << " ";
}
cout << endl;
return 0;
}
Step by Step Solution
3.40 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started