-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathTask13Main.java
More file actions
42 lines (33 loc) · 1.17 KB
/
Task13Main.java
File metadata and controls
42 lines (33 loc) · 1.17 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
41
42
package com.example.task13;
public class Task13Main {
public static void main(String[] args) {
//здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат
// например вот так:
/*
int[] arr = {9, 1100, 7, 8};
removeMoreThen1000(arr);
System.out.println(java.util.Arrays.toString(arr));
*/
}
static int[] removeMoreThen1000(int[] arr) {
//todo напишите здесь свою корректную реализацию этого метода, вместо существующей
if (arr == null || arr.length == 0){
return arr;
}
int count = 0;
for (int i = 0; i < arr.length; i++){
if (arr[i] < 1000){
count += 1;
}
}
int[] arrNew = new int[count];
int index = 0;
for (int i = 0; i < arr.length; i++){
if (arr[i] < 1000){
arrNew[index] = arr[i];
index += 1;
}
}
return arrNew;
}
}