-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinMax4.java
More file actions
22 lines (18 loc) · 570 Bytes
/
MinMax4.java
File metadata and controls
22 lines (18 loc) · 570 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package minmax;
import java.util.Scanner;
public class MinMax4 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int min = Integer.MAX_VALUE, minIndex = 0;
for (int i = 1; i <= n; i++) {
System.out.print(i + "-");
int a = scanner.nextInt();
if (min > a) { // 5 -10 2 9 30
min = a; // min = 5
minIndex = i; // minIndex = 1
}
}
System.out.println(minIndex);
}
}