Input n (n <= 100) integers, and output them after sorting according to the absolute value. The title guarantees that for each test case, the absolute values of all numbers are not equal.
There are multiple groups of input data. Each group occupies one line. The first number of each line is n, followed by n integers. N = 0 means the end of the input data. No processing is performed.
For each test instance, the sorted results are output, separated by a space between the two numbers. One line per test instance.
1 | 3 3 -4 2 |
1 | -4 3 2 |
Turn then into positive numbers and sort. And for each unit in array, if it’s negative originally, turn it back to negative.
1 |
|