[Jobdu] 题目1516 : 调整数组顺序使奇数位于偶数前面

 1 void diffOddAndEven(int a[], int n) {
 2     int low = 0, high = n - 1;
 3     int pivot;
 4     while (low < high) {
 5         while (a[high] % 2 == 0 && low < high)
 6             high--;
 7         while (a[low] % 2 == 1 && low < high)
 8             low++;
 9         pivot = a[low];
10         a[low] = a[high];
11         a[high] = pivot;
12     }
13 }
原文地址:https://www.cnblogs.com/tonyhu1993/p/4699630.html