(자바) 백준 #10818: 최소, 최대

https://www.acmicpc.net/problem/10818

접근법: 값을 하나씩 받아 for 문을 통해 최소값과 최대값을 찾는다.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
    public static void main(String() args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(br.readLine());
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        StringTokenizer st = new StringTokenizer(br.readLine());
        for (int i = 0; i < num; i++) {
           int input = Integer.parseInt(st.nextToken());
           max = Math.max(max,input);
           min = Math.min(min,input);

        }

        System.out.println(min);
        System.out.println(max);
    }
}