#K67027. Double Positives
Double Positives
Double Positives
In this problem, you are given a list of integers. Your task is to produce a new list where every positive integer is doubled, while negative integers and zero remain unchanged.
More formally, given an array (a_1, a_2, \ldots, a_n), you need to construct an array (b_1, b_2, \ldots, b_n) such that:
[
b_i = \begin{cases}
2 \times a_i, & \text{if } a_i > 0, \
a_i, & \text{if } a_i \le 0.
\end{cases}
]
You will be given the input via standard input (stdin) and should print the resulting array to standard output (stdout) with the numbers separated by a single space.
inputFormat
The input consists of two lines. The first line contains a single integer (n) representing the number of elements in the list. The second line contains (n) space-separated integers.
outputFormat
Output a single line containing the modified list of integers. Each number should be separated by a single space. If the list is empty, output nothing.## sample
4
1 2 3 4
2 4 6 8