logo CodeStepByStep logo

vectorMystery1

Language/Type: C++ Vector collections

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

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.