I have written a program that will remove value in the location as given by the user in my vector; but, I misunderstood what I needed to do with my function.
I need to have it iterate through my vector and remove any instances of the number provided by the user.
I feel I could adjust what I have slightly to make this work if it was just one instance of the number.
Would my function need to be coded differently if the number given by the user occurs more than once?
I can make the elements shift to the left and maintain the order when it is just one location being removed; but, I am second guessing myself as to what to do if its more than one number being removed.
What do I need to do differently?
Here is what I have:
A key part of programming is using functions as building blocks.
Make a new function that looks through a vector for a number to remove, and if you find it, call the deletionO function to remove the element at that location. Then, wind location back one (because you moved everything after that location one to the left), and keep looking through the vector for the number to remove. If you find it, call the deletionO function to remove the element at that location. Then, wind location back one (because you moved everything after that location one to the left), and keep looking through the vector....
This would be a simple addition to your code, in which you call the deletionO function you've already created.
Thank you, I am working on writing the new function now.
I believe I see how to do this the only thing I'm confused about is when you say to wind location back one, do I want to do this inside the for loop after the deletionO function is called? My best guess as to what to do is to subtract one from the location; but, I am not entirely sure if that is correct