标签:span class i++ des 奇数 tle order pre 调整
1 public class Solution { 2 public void swap(int [] array, int a, int b) { 3 int temp = array[a]; 4 array[a] = array[b]; 5 array[b] = temp; 6 } 7 public void reOrderArray(int [] array) { 8 int n = array.length; 9 int i = 0; 10 int odd = 0; 11 while (i < n) { 12 if (array[i] % 2 == 1) { 13 for (int j = i; j - 1 >= odd; --j ) 14 swap(array, j, j - 1); 15 odd++; 16 } 17 i++; 18 } 19 } 20 }
标签:span class i++ des 奇数 tle order pre 调整
原文地址:https://www.cnblogs.com/hyxsolitude/p/12323063.html