标签:hdu
3 3 -4 2 4 0 1 2 -3 0
-4 3 2 -3 2 1 0
#include <iostream> #include <cmath> using namespace std; int main() { int n, a[110], t; while (cin >> n && n) { for (int i=0; i<n; i++) { cin >> a[i]; } for (int i=0; i<n-1; i++) { for (int j=1; j<n-i; j++) { if (abs(a[j]) > abs(a[j-1])) { t= a[j]; a[j] = a[j-1]; a[j-1] = t; } } } cout << a[0]; for (int i=1; i<n; i++) { cout << " "<< a[i] ; } cout<< endl; } return 0; }
标签:hdu
原文地址:http://blog.csdn.net/xiaotan1314/article/details/46013259