# HDU 2020 绝对值排序

/***********************
*Programme:绝对值排序
*Programmer:By
*Date:2016/05/30
************************/
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int n;
int arr[105];
while(cin >> n,n != 0){
for(int i = 0;i < n;i ++){
cin >> arr[i];
}
//冒泡排序法
int tem;
for(int i=0;i<n;i++){
for(int j=0;j<n-1-i;j++){
if(abs(arr[j])<abs(arr[j+1])){
tem=arr[j];
arr[j]=arr[j+1];
arr[j+1]=tem;
}//end of if
}//end of inner for
}//end of outer for
for(int i = 0;i < n;i ++){//注意输出格式
if(i != n-1) cout << arr[i] <<" ";
else cout << arr[i]<<endl;
}
}
return 0;
}

//还可以用sort函数
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
bool compare(int a,int b)
{
return abs(a)>abs(b);
}
int main(void)
{
int n;
while(cin >> n && n)
{
int arr[105];
for(i = 0;i < n;i ++)
cin >> arr[i];

sort(a,a+n,compare);

for(i = 0;i < n;i ++){
if(i)
cout << " ";
cout << a[i];
}
cout << endl;
}
}

06-30 2584

08-12 621

08-08 269

05-18 1104

07-26 72

11-20 37

07-18 7

01-16 255

07-29 551

07-22 293