杭电2020
1 #include<stdio.h> 2 #include<math.h> 3 int a[100]; 4 int main() 5 { 6 int n,i,j,t; 7 while(~scanf("%d",&n)&&n) 8 { 9 for(i=0; i<n; ++i) 10 scanf("%d",&a[i]); 11 for(i=0; i<n-1; ++i) 12 for(j=0; j<n-1-i; ++j) 13 if(abs(a[j])<abs(a[j+1])) 14 { 15 t=a[j]; 16 a[j]=a[j+1]; 17 a[j+1]=t; 18 } 19 for(i=0; i<n; ++i) 20 if(i) 21 printf(" %d",a[i]); 22 else 23 printf("%d",a[i]); 24 printf("\n"); 25 } 26 return 0; 27 }