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.

Recommended Answers

All 3 Replies

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.

Can you use vectors instead of arrays?

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.