알고리즘 문제풀이

Q1427 소트인사이드(java)

JihyunLee 2019. 9. 15. 13:25
반응형

 

참고한 곳 : https://m.blog.naver.com/PostView.nhn?blogId=pgh7092&logNo=221120674715&proxyReferer=https%3A%2F%2Fwww.google.com%2F

 

[백준 알고리즘 JAVA] 1427 소트인사이드

백준 온라인 저지 JAVA 1427번 소트인사이드 문제입니다.문제 : 배열을 정렬하는 것은 쉽다. 숫자가 주...

blog.naver.com

 

내 코드:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
import java.util.Arrays;
 
public class Q1427{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
 
        String line = scan.nextLine();
        int N = line.length();
        
        char[] ary = new char[N];
 
        for(int i=0; i<N; i++){
            ary[i] = line.charAt(i);
        }
 
        Arrays.sort(ary);
 
        for(int i=N-1; i>=0; i--){
            System.out.print(ary[i]);
        }
    }
}
cs
반응형