http://acm.hdu.edu.cn/showproblem.php?pid=2020
#include <bits/stdc++.h>
using namespace std;
int a[111];
bool cmpabs(int x,int y)
{
return abs(x)>abs(y);
}
int main()
{
int n,falg=0;
while(~scanf("%d",&n))
{
if(n==0)
break;
else
{
for(int i=1; i<=n; i++)
{
scanf("%d",&a[i]);
}
sort(a+1,a+1+n,cmpabs);
for(int i=1; i<=n; i++)
{
if(i!=n)
printf("%d ",a[i]);
else
printf("%d\n",a[i]);
}
}
}
return 0;
}
原文:https://www.cnblogs.com/zlrrrr/p/9321155.html