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++;
}
}
};
原文地址:https://www.cnblogs.com/theodoric008/p/9534976.html
时间: 2024-10-31 16:52:17