본문 바로가기

코딩 테스트/프로그래머스

[Level 1, C++] 정수 내림차순으로 배치하기

728x90
반응형

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

long long solution(long long n) {
    long long answer = 0;
    string str = to_string(n);
    sort(str.begin(), str.end(), greater<>( ));
    answer = stoull(str);
    return answer;
}
728x90
반응형