剑指offer---调整数组顺序使奇数位于偶数前面
class Solution { public: void reOrderArray(vector<int> &array) //加个&表示引用 { int array_size = array.size(); //int xiabiao = (array_size - 1); vector<int> brray; for (int i = 0; i < array_size; ++i) { brray.push_back(array[i]); } int i = 0; int k = 0; int j = 0; while (i < array_size) { if ((brray[i]) % 2 != 0) { array[k] = brray[i]; ++k; } ++i; } while (j < array_size) { if ((brray[j]) % 2 == 0) { array[k] = brray[j]; ++k; } ++j; } } };