logo CodeStepByStep logo

vectorMystery1

Language/Type: C++ Vector collections
Author: Marty Stepp (on 2016/06/16)

Write the final contents when the following function is passed each vector below:

void vectorMystery1(Vector<int>& v) {
    for (int i = 0; i < v.size(); i++) {
        int n = v[i];
        if (n % 10 == 0) {
            v.remove(i);
            v += n;
        }
    }
    cout << v << endl;
}
{1, 20, 3, 40}
{80, 3, 40, 20, 7}
{40, 20, 60, 1, 80, 30}

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.