Moving Zeroes to the End · Compiler

Moving Zeroes to the End

Move all zeroes to the end of an array while keeping the other values in their original order.

Input
Line 1 contains the length n (1 to 100). Line 2 contains n space-separated integers, each from -1000 to 1000.
Output
Print all n values of the resulting array on one line, separated by spaces.

Compiler Explorer runs your code when you run or check it.

Loading your exercise draft…