Question: C++ 3. Implement the removeOdds function; you must use vector's erase member function: #include #include #include #include using namespace std; // Remove the odd integers

C++

3. Implement the removeOdds function; you must use vector's erase member function:

 #include  #include  #include  #include  using namespace std; // Remove the odd integers from v. // It is acceptable if the order of the remaining even integers is not // the same as in the original vector. void removeOdds(vector& v) { } void test() { int a[8] = { 2, 8, 5, 6, 7, 3, 4, 1 }; vector x(a, a+8); // construct x from the array assert(x.size() == 8 && x.front() == 2 && x.back() == 1); removeOdds(x); assert(x.size() == 4); sort(x.begin(), x.end()); int expect[4] = { 2, 4, 6, 8 }; for (int k = 0; k < 4; k++) assert(x[k] == expect[k]); } int main() { test(); cout << "Passed" << endl; } 

For this problem, you will turn a file named odds.cpp with the body of the removeOdds function, from its "void" to its "}", no more and no less. Your function must compile and work correctly when substituted into the program above.

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!