Hello world! So situation is as follows. I'm total beginner in C++ and it is first language I am learning. I have this task given:
From array A(2n) I need to get two arrays B(n) and C(n)as follows: in array A I need to find two closest numbers. Smallest I need to put in array B, but biggest into array C. I need to continue this until all elements are out of array A and into array B and C.
Ok I understand I need to sort array A and find the closest values, but I don't understand how to divide that array A into two separate arrays.
I made this to find closest values in array. I can give the values i found to arrays B and C. I don't understand how to delete them from array A so I can find next two closest values. Can someone help.
You could 'delete' them by moving all other elements at higher indexes to the left and decrease the number of elements in the array you're processing. Or, you could keep a parallel array with boolean values that indicates whether or not an element at a particular index has been processed already, and just skip values that have already been processed.