Sort the vector of numbers in order low-high-low. Even numbers appear in ascending order on the left and odd numbers appear in descending order on the right.
x = [ 5 3 4 1 2 ]
the output is:
y = [ 2 4 5 3 1 ]
I don't understand if the smallest element should be the last or the first of the sorted array
Thanks for creating a problem! It's a little ambiguous right now (see @andrea84's comment above). There is more than one answer as currently defined. Could you please clarify it?
Sorry for that, if you have input odd vector the smallest element is on the end, but if u input even vector the smallest element is on the first position.
Finding Perfect Squares
Increment a number, given its digits
Specific Element Count
Return unique values without sorting
Add two numbers
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office