-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinMax18.java
More file actions
30 lines (27 loc) · 782 Bytes
/
Copy pathMinMax18.java
File metadata and controls
30 lines (27 loc) · 782 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
27
28
29
30
package minmax;
import java.util.Scanner;
public class MinMax18 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int n;
int r;
System.out.println("N:");
n= scanner.nextInt();
int max=Integer.MIN_VALUE;
int max1=Integer.MIN_VALUE;
int maxNum=0;
int maxNum1=0;
for (int i = 1; i <=n; i++) {
System.out.print(i + ".");
r = scanner.nextInt();
if (max < r) { // 5 10 2 9 0 10 6 10
max = r; //10
maxNum = i; //2
}
if (max <= r) { // 5 10 2 9 0 10 6
maxNum1 = i;
}
}
System.out.println(maxNum1-maxNum-1);
}
}