본문 바로가기

Problem Solving/백준

[백준/C++] 1427번 소트인사이드


#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    string answer;
    cin >> answer;
    sort(answer.begin(), answer.end(), greater<char>());
    cout << answer;
}

이 문제는 단순하게 알고리즘 헤더파일의 sort와 functional 헤더파일에 있는 greater 함수를 이용하면 간단하게 해결할 수 있다

예전에 greater를 모를 땐 bool function으로 비교하는 함수를 구현했는데 귀찮음을 덜 수 있다!


문제: https://www.acmicpc.net/problem/1427

 

1427번: 소트인사이드

첫째 줄에 정렬하려고 하는 수 N이 주어진다. N은 1,000,000,000보다 작거나 같은 자연수이다.

www.acmicpc.net