[恢]hdu 2020
2011-12-14 04:39:31
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2020
题意:中文
代码:
# include <stdio.h>
# include <stdlib.h>
int a[110] ;
int abs(int n){return n<0?-n:n;}
int cmp(const void *a, const void *b)
{
int aa = *(int*)a, bb = *(int*)b ;
return abs(bb)-abs(aa) ;
}
int main ()
{
int i, n ;
while (~scanf ("%d", &n) && n)
{
for (i = 0 ; i < n ; i++)
scanf ("%d", a+i) ;
qsort(a, n, sizeof(int), cmp) ;
for (i = 0 ; i< n ; i++)
{
if (i ==0)printf ("%d", a[i]) ;
else printf (" %d", a[i]) ;
}
puts ("") ;
}
return 0 ;
}