-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinMax.java
More file actions
26 lines (25 loc) · 616 Bytes
/
MinMax.java
File metadata and controls
26 lines (25 loc) · 616 Bytes
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
import java.util.Scanner;
public class MinMax {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int i;
int n;
int r;
int min = 0;
int minnum=0;
// 3 5 2 4 1
System.out.println("N:");
n= scanner.nextInt();
//
for (i = 1; i <= n; ++i) {
System.out.print(i+"-");
r= scanner.nextInt();
//
if ((r < min) || (i == 1)) {
min = r;
minnum = i-1;
}
}
System.out.println("Minimum:"+minnum);
}
}