剑指offer 调整奇偶数的顺序 转换为调整所有逆序的问题
class Solution {
public:
void reOrderArray(vector<int> &array) {
if(array.empty() || array.size() == 1){
return;
}
auto end = (int)array.size();
int i = 0;
while(i < end){
auto a = array;
if( array[i] % 2 == 0 && array[i+1] % 2 == 1){
auto tmp = array[i];
array[i] = array[i + 1];
array[i + 1] = tmp;
i = -1;
}
i++;
}
}
};