logo CodeStepByStep logo

vectorMysteryRemove

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

What are the contents of the vector after the following code executes?

Vector<int> vec;
for (int i = 1; i <= 8; i++) {
    vec += 10 * i;  //   0   1   2   3   4   5   6   7
}                   // {10, 20, 30, 40, 50, 60, 70, 80}
for (int i = 0; i < vec.size(); i++) {
    vec.remove(i);
}
cout << vec << endl;
vector contents

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.