#include<stdio.h> #include<math.h> int main() { int n, a[102]; int i, j, t; while (scanf("%d", &n) != EOF) { //输入数据到数组 if (n <= 0) return 0; for (i = 0; i < n; i++) scanf("%d", &a[i]); //冒泡法排序 for (j = 0; j < n - 1; j++) { for (i = 0; i <= n - 1 - j; i++) { if (fabs(a[i]) > fabs(a[i + 1])) { t = a[i]; a[i] = a[i + 1]; a[i + 1] = t; } } } for (i=n-1; i>0; i--) printf("%d ", a[i]); printf("%d\n", a[i]); } return 0; }