leetcode-剑指21-OK

address

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* exchange(int* nums, int numsSize, int* returnSize){
	int i = 0, j = numsSize-1;
	while(i<j){
		while((i<numsSize)&&(nums[i]%2==1)){
			i++;
		}
		while((j>=0)&&(nums[j]%2==0)){
			j--;
		}
		if(i<j){
			returnSize[0] = nums[i];
			nums[i] = nums[j];
			nums[j] = returnSize[0];
		}
	}
	returnSize[0] = numsSize;
	return nums;
}
上一篇:C++ Builder之StringGrid表格简单示例(TStringGrid控件实例例子)


下一篇:ftrace浅析-龙芯64位平台