白駿1427号:内線



質問リンク
入力した数字を1つずつ配列に分けて格納し、降順に並べて出力すればよい.

Javaを使用した解答

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		String n = br.readLine();							//문자열로 입력받아
		Character[] nArr = new Character[n.length()];		//문자열 길이만큼 배열 생성
		
		for(int i = 0; i < nArr.length; i++) {
			nArr[i] = n.charAt(i);							//배열에 숫자를 넣어주고
		}
		
		Arrays.sort(nArr, Collections.reverseOrder());		//내림차순 정렬
		for(int i = 0; i < nArr.length; i++) {
			bw.write(nArr[i]);								
		}
		
		bw.flush();
	}
	
}