2011-12-15 23:42:25
地址:http://acm.hdu.edu.cn/showproblem.php?pid=1040
题意:给n个数,排序后输出。
代码:
# include <stdio.h>
# include <stdlib.h>
int a[1010] ;
int cmp(const void *a, const void *b)
{
return *(int*)a - *(int*)b ;
}
int main ()
{
int i, T, n ;
scanf ("%d", &T) ;
while (T--)
{
scanf ("%d", &n) ;
for (i = 0 ; i < n ;i++)
scanf ("%d", &a[i]) ;
qsort(a, n, 4, cmp) ;
for (i = 0 ; i < n ; i++)
if (i == 0) printf ("%d", a[i]) ;
else printf (" %d", a[i]) ;
printf ("\n") ;
}
return 0 ;
}