Hi, i am trying to reorganize the numbers so that the odds are first from smallest to largest and the evens are after from largest to smallest.
for example: {-19, 270, 76, -61, 54} would be {-61, -19, 270, 76, 54}
@keskiverto i wrote the code in codeblocks and it compiled and ran successfully with 0 errors.
Besides, kni9ht says "My assignment says i must use arrays. .
Codeblocks probably uses GCC and GCC offers by default has some non-standard extensions, including VLA for C++. Not standard, not portable. The C++ standard method for dynamic-sized array is std::vector.
Practically every early assignment says must use brains. Use of all language features is tertiary. One can call std::partition and std::sort with array, but that is not the goal.
We, the caller of std::partition, have only one array. What does that function do? Does it use additional memory as workspace? It does not have to. You can peek the documentation in that link. You will see code. However, that could turn your assigment task from inventing a wheel to adapting a Ferrari's wheel into your bicycle. Different part of the brain.
You partition by copying to two new arrays. You could reserve three arrays of same constant size. You do count odds and evens as you copy them, so you will know how much of each array you do use. These arrays are tiny, so the waste of memory is insignificant; VLA is simply not needed.
What about the two calls to std::sort?
How can same algorithm sort differently? There is a fundamental trick there; we can give a function a helper function as parameter that changes what the primary function does. In this case we could simply have a sort function that takes a bool parameter to choose between ascending and descending.
There is more. Your sort operates on the first N elements of an array. The std::sort operates on range. Yet another useful concept to divert the already overloaded kni9ht.