-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArray38.java
More file actions
28 lines (24 loc) · 634 Bytes
/
Array38.java
File metadata and controls
28 lines (24 loc) · 634 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
package array;
/**
* Project Admin -> Husanboy Azamov
* Package Name -> array
* Class Name -> Array38
* Copyright © : 6/23/2022
*/
public class Array38 {
public static void main(String[] args) {
monotonEncirment(new int[]{9,3,4,2,3,4,1});
}
public static void monotonEncirment(int[] array) {
int num=0;
for (int i = 2; i < array.length; i++) {
if ((array[i-2]>array[i-1]) && !(array[i-1]>array[i])){
num++;
}
}
if (array[array.length-2]>array[array.length-1]){
++num;
}
System.out.println(num);
}
}