1 #include<stdio.h> 2 #include<math.h> 3 #include<string.h> 4 #include<string.h> 5 6 int a[1001]; 7 8 int partitions(int a[],int low,int high) 9 { 10 int pivotkey=a[low]; 11 while(low<high) 12 { 13 while(low<high && a[high]>=pivotkey) 14 --high; 15 a[low]=a[high]; 16 while(low<high && a[low]<=pivotkey) 17 ++low; 18 a[high]=a[low]; 19 } 20 a[low]=pivotkey; 21 return low; 22 } 23 24 void qsort(int a[],int low,int high) 25 { 26 int pivottag; 27 if(low<high) 28 { 29 pivottag=partitions(a,low,high); 30 qsort(a,low,pivottag-1); 31 qsort(a,pivottag+1,high); 32 } 33 } 34 void deal(int a[], int n) 35 { 36 int i; 37 qsort(a,0,n-1); 38 for(i=0; i<n; i++) 39 { 40 if(i>0) 41 printf(" "); 42 printf("%d",a[i]); 43 } 44 printf("\n"); 45 46 } 47 48 void solve() 49 { 50 int T,i,n; 51 while(scanf("%d",&T)!=EOF) 52 { 53 while(T--) 54 { 55 scanf("%d",&n); 56 for(i=0; i<n; i++) 57 { 58 scanf("%d",&a[i]); 59 } 60 deal(a,n); 61 } 62 } 63 } 64 65 int main() 66 { 67 solve(); 68 return 0; 69 }