Given an array input [], if the array length N is an odd number, place the largest element in the array in the middle of the output [] array. If the array length N is an even number, place the largest element in the array to the right of the two locations in the middle of the output [] array, and then place the elements in the order of size to size on both sides of the first position in sequence, store the remaining number in the order of one left and one right.
For example: input [] = {3, 6, 1, 9, 7} output [] = {3, 7, 9, 6, 1}; input [] = {3, 6, 1, 9, 7, 8} output [] = {1, 6, 8, 9, 7, 3}
Function interface void sort (INT input [[, int N, int output [])
# Include <algorithm> using namespace STD; bool CMP (int A, int B) {return (A> B);} void sort (INT input [], int N, int output []) {/* int small; // bubble sort method for (INT I = 1; I <n; I ++) {for (Int J = 0; j <n-I; j ++) {If (input [J] <input [J + 1]) {int temp = input [J]; input [J] = input [J + 1]; input [J + 1] = temp ;}} */sort (input, input + N, CMP ); // if the function name you write is sort, you can also use the sort function for (INT I = 0; I <N; I ++) cout <input [I] <"; int mid = n/2; Output [Mid] = input [0]; int IBIG = mid-1, ismall = Mid + 1; for (INT I = 1; I <n;) {If (IBIG> = 0) Output [IBIG --] = input [I ++]; if (ismall <n) Output [ismall ++] = input [I ++] ;}}