Question: Given an integer vector listVals with six elements and an input integer numDeleted, resize listVals to remove numDeleted elements from the vector. Ex: If the

Given an integer vector listVals with six elements and an input integer numDeleted, resize listVals to remove numDeleted elements from the vector.

Ex: If the input is 1, then the output is:

The beginning 9 8 11 12 13 10 The end The beginning 9 8 11 12 13 The end

Note: Assume that numDeleted is a non-negative integer less than or equal to the vector's size.

#include #include using namespace std;

int main() { vector listVals(6); int initListValsSize = listVals.size(); int numDeleted; int i;

listVals.at(0) = 9; listVals.at(1) = 8; listVals.at(2) = 11; listVals.at(3) = 12; listVals.at(4) = 13; listVals.at(5) = 10;

cin >> numDeleted;

cout << "The beginning "; for (i = 0; i < listVals.size(); ++i) { cout << listVals.at(i) << " "; } cout << "The end" << endl;

/* Your code goes here */

cout << "The beginning "; for (i = 0; i < listVals.size(); ++i) { cout << listVals.at(i) << " "; } cout << "The end" << endl;

return 0; }

C++ please

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!