标签:
class Solution { public: void reOrderArray(vector<int> &array) { int odd=0,even=0; int len=array.size(); while(even<len) { while(even<len &&( (array[even]&1)==1)) even++; odd=even+1; while(odd<len&&((array[odd]&1)==0)) odd++; if(odd>=len)break; int tmp=array[odd]; for(int i=odd;odd>even;odd--) array[odd]=array[odd-1]; array[odd]=tmp; even++; } return; } };
标签:
原文地址:http://www.cnblogs.com/daocaorenblog/p/5348426.html