코딩테스트/프로그래머스
[Level 1][C++] 정수 내림차순으로 배치하기
MJ.Lee
2024. 9. 30. 20:47
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
long long solution(long long n) {
string s = to_string(n); //long long을 string으로 변환
sort(s.begin(), s.end(), greater<char>()); //내림차순으로 정리
long long answer = atoll(s.c_str()); //string을 long long 형으로 바꾸는 것. int형으론 atoi
return answer;
}