Playground/자바문제집

[백준] 1427번

미숫가루설탕많이 2023. 4. 10. 21:57
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int[] A = new int[str.length()];

        for (int i = 0; i < str.length(); i++) {
            A[i] = Integer.parseInt(str.substring(i, i + 1));
        }

        for (int i = 0; i < str.length(); i++) {
            int max = i;

            for (int j = i + 1; j < str.length(); j++) {
                if (A[j] > A[max]) {
                    max = j;
                }
            }

            if (A[i] < A[max]) {
                int temp = A[i];
                A[i] = A[max];
                A[max] = temp;
            }
        }

        for (int i = 0; i < str.length(); i++) {
            System.out.print(A[i]);
        }
    }
}
 

'Playground > 자바문제집' 카테고리의 다른 글

[프로그래머스] 완주하지 못한 선수  (0) 2023.05.13
[프로그래머스] 문자열 바꿔서 찾기  (0) 2023.05.09
[백준] 11286번  (0) 2023.04.07
[백준] 2164번  (0) 2023.04.07
[프로그래머스] 피보나치 수  (0) 2023.04.07