-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinMax20.java
More file actions
40 lines (37 loc) · 1.04 KB
/
MinMax20.java
File metadata and controls
40 lines (37 loc) · 1.04 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
39
40
package minmax;
import java.util.Scanner;
public class MinMax20 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n;
int counterMax=0;
int counterMin=0;
int r;
int min=Integer.MAX_VALUE;
int max=Integer.MIN_VALUE;
n = scanner.nextInt();
for (int i = 1; i <= n; i++) {
System.out.print(i+".");
r= scanner.nextInt();
//
if ((r < min) || (i == 1)) {
min = r;
counterMin = 0;
}
//
if ((r > max) || (i == 1)) {
max = r;
counterMax = 0;
}
//
if (r == min) {
++counterMin;
} else if (r == max)
++counterMax;
//
}
System.out.println(counterMax+counterMin);/*
Eksteremal elementligi uchun: (counterMax +counterMin) Ekstremal element deb eng katta yoki eng kichik elemntga aytiladi
*/
}
}