Hi, I need to make a program, which I think should be simple if you know what you are doing.

You have an array of integers A(m, n) and B(m). Delete an element from A array, which index is in the B(m) array. Print original and modified arrays.

I don't really know how should I do it. I have made two files for the input (for A and B) and made the program to compile and present the result in the output file. Now, the only thing left is this function. Any help would be appreciated.

8 Years
Discussion Span
Last Post by Snippset

Of course you can't really delete an element in an array, just shift all remaining array elements up to write over the element you want deleted and leave an empty element at the end of the array. If you have an array with 5 elements and you want to delete the 2d one, then move 3 to 2, 4 to 3, and 5 to 4, leaving 5th element unused.

Another way to do it without all that shifting is to just replace the current value of the element with some special number that indicates it is deleted. Then when doing anything with the array just skip over the element that is marked for deletion.


You can't use vectors, it's arrays only. As I said, it shouldn't be difficult, if you know how to work in c++. But I'm newbie...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.