Zeroing Out Invalid Readings
A footfall counter above the door of each Riverbend Supply shop reports how many people came through in the last minute. A minute can never truly have negative traffic; when the beam is knocked out of line the hardware files a negative spike instead. Operations treat any negative minute as no traffic at all. The minute cannot simply be thrown away, because the series is plotted against the clock and a missing minute would shift every later point.
Task: Print the series with every negative minute reading as 0, keeping the original order.
Input
The first line holds a single integer n, the number of minutes. Each of the next n lines holds one count: a whole number, possibly negative.
Output
One line holding all n counts in their original order, separated by single spaces. Every negative count reads as 0, and every other count is unchanged. No brackets and no commas.
Example:
Input:
4
5
-2
8
-1
Output:
5 0 8 0
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in