llllmz

导航

283. 移动零c

void moveZeroes(int* nums, int numsSize) {
    int head=0,index=0;
    while(index<numsSize){
        if(nums[index]!=0){
            nums[head++]=nums[index];
        }
        index++;
    }
    for(;head<numsSize;head++) nums[head]=0;
}

 

posted on 2024-03-18 15:39  神奇的萝卜丝  阅读(18)  评论(0)    收藏  举报