1327: 【中级组】移动零到末尾
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:254
Solved:105
Description
给定一个数组 nums及其长度n,编写一个程序,将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。
Input
输入为两行:第一行数组中元素的个数n(1=<n=<10000),第二行是n个整数,每两个整数之间用空格分隔。
Output
将所有 0 移动到数组的末尾后输出这个数组,同时保持非零元素的相对顺序。数字间空一格。
Sample Input Copy
6
0 2 3 0 7 8
Sample Output Copy
2 3 7 8 0 0