Problem3418--移动到末尾

3418: 移动到末尾

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MiB

Description

给定一个数组,实现一个算法将数组中的所有 0 移动到末尾,但不可改变非 0 数字的相对位置。介绍如下:

  • 例如数组为 [0, 1, 0, 3, 12],将所有 0 移动到末尾的结果为 [1, 3, 12, 0, 0]。

Input

第一行输入一个数字 lns="http://www.w3.org/1998/Math/MathML">N (1<N<1000),为数组的长度。

第二行输入数组的元素 lns="http://www.w3.org/1998/Math/MathML">Ailns="http://www.w3.org/1998/Math/MathML">0<Ai<1000

Output

输出一行,为移动后数组。

Sample Input Copy

5
0 1 0 3 12

Sample Output Copy

1 3 12 0 0

Source/Category