Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
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
more
Archives
Today
Total
관리 메뉴

지극히 개인적인 개발블로그

백준 알고리즘 2750: 수 정렬하기(Java) 본문

알고리즘

백준 알고리즘 2750: 수 정렬하기(Java)

코드분쇄기 2019. 10. 19. 11:53

문제 풀이: c++에선 벡터를 많이 썻다면 자바에서는 ArrayList를 많이 쓴느 것 같네요. 그 사용방법을 한번 익혀봤습니다.

import java.util.*;
public class Sol_2750 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            list.add(num);
        }
        Collections.sort(list);
        for(int i:list)
            System.out.println(i);
    }
}