본문 바로가기
프로그래밍/알고리즘

[백준] 10818번: 최소, 최대 (JAVA)

by 공대부부 남편 2022. 3. 8.
728x90
반응형

 

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        int[] arr = new int[N];
        int idx = 0;
        
        StringTokenizer st = new StringTokenizer(br.readLine(), " ");
        while(st.hasMoreTokens()) {
        	arr[idx] = Integer.parseInt(st.nextToken());
        	idx++;
        }
        Arrays.sort(arr);
        System.out.println(arr[0] + " " + arr[N-1]);
    }
}

 

728x90
반응형