프로그래머스_C#/Level_1
[프로그래머스 C#] 정수 내림차순으로 배치하기
최애뎡
2021. 8. 11. 00:17
728x90
반응형
using System;
public class Solution {
public long solution(long n) {
long answer = 0;
char[] _charTemp = n.ToString().ToCharArray();
System.Array.Sort(_charTemp);
System.Array.Reverse(_charTemp);
string _strTemp = new string(_charTemp);
answer = Convert.ToInt64(_strTemp);
return answer;
}
}
string으로 바꾸고
정렬하기 쉽게 Array로 바꾸고
정렬하고
다시 long으로 바꾸기 위해 역순으로
string으로 바꾸고
long으로 바꾸고
반응형