public class Solution { public int[] SortArrayByParityII(int[] A) { var len = A.Length; int[] ODD = new int[len / 2];//奇数1,3,5,7,9 int[] EVEN = new int[len / 2];//偶数0,2,4,6,8 int x = 0; int y = 0; for (int i = 0; i < len; i++) { if (A[i] % 2 == 0) { EVEN[x] = A[i]; x++; } else { ODD[y] = A[i]; y++; } } x = 0; y = 0; for (int i = 0; i < len; i++) { if (i % 2 == 0) { A[i] = EVEN[x]; x++; } else { A[i] = ODD[y]; y++; } } return A; } }