Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- divide and conquer
- heap
- 15552번
- 스터디
- 코딩테스트
- 거품정렬
- 스택
- LinkedList
- Timsort
- 우선순위 큐
- stack
- 백준
- 힙
- 코테
- 파싱
- 해시함수
- 자료구조
- collections.sort
- 트라이
- 큐
- 선택정렬
- 코테준비
- 프로그래머스
- 분할정복
- 이진트리탐색
- 연결리스트
- 퀵정렬
- 삽입정렬
- MSA
- 팀정렬
Archives
- Today
- Total
Little bIT awesome
배열 역순으로 정렬하기 본문
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String n = br.readLine();
String[] arr = n.split("");
Integer[] arrInt = new Integer[arr.length];
for (int i = 0; i < arr.length; i++) {
arrInt[i] = Integer.parseInt(arr[i]);
}
Arrays.sort(arrInt, Collections.reverseOrder());
for (Integer x : arrInt) System.out.print(x);
}
}
꼭 기본형으로 지정해주어야 함.
int[] → Integer[]
'코딩테스트 > 백준' 카테고리의 다른 글
BufferedWriter (백준 15552번) (1) | 2024.01.04 |
---|---|
[Java] BufferedReader & BufferedWriter (2) | 2024.01.03 |