정수 N개가 주어졌을 때 이때 최대 최소 값을 구해라.
5 -> 20, 10, 35, 30, 7 || 7, 35
import java.util.Scanner;
public class Main10818 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] arr = new int[N];
for (int i = 0; i < N; i++) {
arr[i] = sc.nextInt();
}
int max = arr[0];
for (int i = 0; i < arr.length; i++) {
if (arr[i] > max){
max = arr[i];
}
}
int min = arr[0];
for (int i = 0; i < arr.length; i++) {
if (arr[i] < min){
min =arr[i];
}
}
System.out.println(min + " " + max);
}
}
import java.util.Arrays;
import java.util.Scanner;
public class Main10818_1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] n = new int[N];
for (int i = 0; i < N; i++) {
n[i] = sc.nextInt();
}
Arrays.sort(n);
System.out.println(n[0] + " " + n[N - 1]);
}
}
public class 최대최소_1 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer stkr = new StringTokenizer(br.readLine());
int N = Integer.parseInt(stkr.nextToken());
int min = 1000000, max = -1000000;
for (int i = 0; i < N; i++) {
int num = Integer.parseInt(stkr.nextToken());
if (num > max)
max = num;
if (num < min)
min = num;
}
System.out.println(min + " " + max);
}
}