Title: Enter an array of integers to implement a function to adjust the order of the numbers in the array, so that all the odd digits are in the first half of the array, all the even digits are located in the second half of the array, and the relative positions of the odd and odd, even and even are guaranteed.
Idea: To think that the original order is relatively unchanged, can only be adjacent to the exchange or sequential movement. Bubble sort: One finds adjacent two, the previous one is even, the latter is an odd number, then the exchange.
Public classReorderarrayclass { Public voidReorderarray (int[] Array) { for(inti = 0; i < Array.Length; i++) { for(intj = 0; J < Array.length-1; J + +) { if(Array[j]% 2 = = 0 && array[j + 1]% 2! = 0) { intTMP =Array[j]; ARRAY[J]= Array[j + 1]; Array[j+ 1] =tmp; } } } }}
"The point of the sword" adjusts the array order so that the odd digits are preceded by even numbers