#K51792. Modify and Sort Array
Modify and Sort Array
Modify and Sort Array
You are given an array of integers. Your task is to process the array by performing the following steps:
- Remove all negative numbers.
- Square each of the remaining numbers. That is, for each number \(x\) such that \(x \ge 0\), compute \(x^2\).
- Sort the resulting numbers in non-decreasing order.
The input will be read from standard input (stdin) and the output must be printed to standard output (stdout). Ensure that you follow the input and output format precisely.
Example:
Input: 7 -3 -1 0 2 4 -2 3</p>Output: 0 4 9 16
inputFormat
The input consists of two lines:
- The first line contains a single integer \(n\) denoting the number of elements in the array.
- The second line contains \(n\) space-separated integers.
outputFormat
Output the modified array after performing the operations. The numbers must be printed in a single line separated by a single space.
If the resulting array is empty, output an empty line.
## sample7
-3 -1 0 2 4 -2 3
0 4 9 16