Programming/Baekjoon

백준 11931 c++ 수 정렬하기4

fishersheep 2022. 3. 16. 20:43
반응형
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <string>
#include <set>

using namespace std;

bool cmp(int a, int b)
{
    return a > b;   //내림차순
}

int main()
{
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);

    int n,temp;
    vector<int>v;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        v.push_back(temp);
    }

    sort(v.begin(), v.end(), cmp);  //정렬

    for (int i = 0; i < v.size(); i++)
        cout << v[i] << '\n';

    return 0;
}
반응형