HDOJ 2020 绝对值排序

时间:2022-10-06 16:12:01
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;
bool cmp(int a, int b) {
    return abs(a) > abs(b);
}

int main() {
    int n;
    ) {
        vector<int> v;
        int t;
        ;i < n;i++) {
            cin >> t;
            v.push_back(t);
        }
        sort(v.begin(), v.end(), cmp);
        for (auto it = v.begin();it != v.end();it++) {
            if (it == v.begin()) cout << *it;
            else cout << " " << *it;
        }
        cout << endl;
    }

    ;
}