백준 #10818번 최소, 최대

jhj·2024년 2월 18일

백준 JAVA

목록 보기
381/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		int max = a[0];
		int min = a[0];
		for(int i = 0; i < n; i++) {
			max = Math.max(max, a[i]);
			min = Math.min(min, a[i]);
		}
		
		System.out.print(min + " " + max);
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글