Absolute Value sorting Time Limit: 1000 ms Memory limit: 65536 K any questions? Click Here ^_^ Enter n (n <= 100) integers in the topic description and sort them by absolute values in ascending order. The question ensures that the absolute values of all numbers are not equal for each test instance. There are multiple groups of input data. Each group occupies one row. The first number in each row is n, followed by n integers. n = 0 indicates the end of the input data and is not processed. Output the sorted results for each test instance. separate the two numbers with a space. Each test instance occupies one row. Sample Input
3 3 -4 24 0 1 2 -30
Sample output
-4 3 2-3 2 1 0
# Include
# Include
Void main ()
{
Int a [100], n, I, j, t, k;
While (scanf ("% d", & n)
{
For (I = 0; I {
Scanf ("% d", & a [I]);
}
For (I = 0; I <= n-2; I ++)
{
For (j = I + 1; j <= n-1; j ++)
If (abs (a [j])> abs (a [I])
{
T = a [j];
A [j] = a [I];
A [I] = t;
}
}
For (I = 0; I {
If (I Printf ("% d", a [I]);
Else printf ("% d", a [I]);
}
Printf ("\ n ");
}
}