Home > Back-end >  ZCMU sort of absolute value of 1319
ZCMU sort of absolute value of 1319

Time:12-20

The Description
Type n (n<=100), an integer, according to the absolute value from big to small sorted output, subject guarantee for each test case, all the absolute value of number is not equal,

Input
How much input data set, each group of a line, each row of the first number is n, followed by n integers, n=0 means the end of the input data, don't do processing,

The Output
For each test case, the output is sorted as a result, the two Numbers, separated by a space between each test instance a line

The Sample Input
3 3-4 2
4 0 1 2-3
0
The Sample Output
- 4 3 2
- 3 2 1 0
Code:
#include
using namespace std;
Int main ()
{
Int n, c;
While (~ the scanf (" % d ", & amp; N))
{
If (n==0)
break;
Int a [n].
for(int i=0; i{
The scanf (" % d ", & amp; A [I]);
}
for(int i=0; i{
for(int j=i+1; J{
If (fabs (a) [I] {
C=a, [I].
A [I]=a, [j].
A [j]=c;
}
}
}
Printf (" % d ", a [0]).
for(int i=1; i{
Printf (" % d ", a [I]);
}
printf("\n");
}
}
  • Related