-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinimumFromN.java
More file actions
38 lines (30 loc) · 1.2 KB
/
MinimumFromN.java
File metadata and controls
38 lines (30 loc) · 1.2 KB
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
32
33
34
35
36
37
38
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
/*
Минимальное из N чисел
1. Ввести с клавиатуры число N.
2. Считать N целых чисел и заполнить ими список - метод getIntegerList.
3. Найти минимальное число среди элементов списка - метод getMinimum.
*/
public class Solution {
public static void main(String[] args) throws Exception {
List<Integer> integerList = getIntegerList();
System.out.println(getMinimum(integerList));
}
public static int getMinimum(List<Integer> array) throws IOException {
return Collections.min(array);
}
public static List<Integer> getIntegerList() throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
List<Integer> myList = new ArrayList<>();
int n = Integer.parseInt(reader.readLine());
for (int i = 0; i < n; i++) {
myList.add(Integer.parseInt(reader.readLine()));
}
return myList;
}
}