题解 | #移动 0#
移动 0
https://www.nowcoder.com/practice/102586387caa4afcbad6f96affce9780
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param nums int整型一维数组
* @param numsLen int nums数组长度
* @return int整型一维数组
* @return int* returnSize 返回数组行数
*/
int* moveZeroes(int* nums, int numsLen, int* returnSize ) {
// write code here
for(int i = 0;i<numsLen;i++){
for(int j = 0;j<numsLen-1-i;j++)
{
if(nums[j]==0)
{
int temp = nums[j];
nums[j] = nums[j+1];
nums[j+1] = temp;
}
}
}
*returnSize = numsLen;
return nums;
}
