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
int main() { vector
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
Get step-by-step solutions from verified subject matter experts
