# 283. Move Zeroes

Given an array `nums`, write a function to move all `0`‘s to the end of it while maintaining the relative order of the non-zero elements.

For example, given `nums = [0, 1, 0, 3, 12]`, after calling your function, `nums` should be `[1, 3, 12, 0, 0]`.

## C++代码：

``` 1 class Solution {
2 public:
3     void moveZeroes(vector<int>& nums) //仿插入排序
4     {
5         int j,tmp;
6         for(int p=1;p<nums.size();p++)
7         {
8             tmp=nums[p];
9             for(j=p;j>0&&tmp!=0&&nums[j-1]==0;j--)
10             {
11                 swap(nums[j],nums[j-1]);
12             }
13             nums[j]=tmp;
14         }
15     }
16 };```

## LeetCode 283. Move Zeroes （移动零）

Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0]. Note: You

## leetCode 283. Move Zeroes 数组

283. Move Zeroes Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12,

## 283. Move Zeroes - LeetCode

Question 283. Move Zeroes Solution 题目大意:将0移到最后 思路: 1. 数组复制 2. 不用数组复制 Java实现: 数组复制 public void moveZeroes(int[] nums) { int[] arr = Arrays.copyOf(nums, nums.length); int start = 0; int end = nums.length - 1; for (int i=0; i<arr.length; i++) { int tmp