-
Notifications
You must be signed in to change notification settings - Fork 0
/
kj.java
31 lines (24 loc) · 909 Bytes
/
kj.java
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
import com.sun.source.tree.NewArrayTree;
import java.util.*;
/*
* @created 15/09/2021 - 14:36
* @project test
* @author note-admin
*/
public class kj {
public static void main(String[] args) {
int[] ints = {0, 2, 4, 6, 8, 10, 11, 123, 112, 44, 53, 5667 ,76835, 45, 5};
OptionalInt max = Arrays.stream(ints).max();
OptionalInt min = Arrays.stream(ints).min();
Integer suma = Arrays.stream(ints).sum();
OptionalDouble avgd = Arrays.stream(ints).average();
System.out.println("minVal = " + min.getAsInt() + "\nmaxVal = " + max.getAsInt() + "\nsumelement = " + suma + "\nAvg = " + avgd.getAsDouble());
System.out.print("Масив нечётных ");
int counter = 1;
for (int i = 0; i < ints.length; i++) {
if (ints[i] % 2 != 0) {
System.out.print(" " + ints[i]);
}
}
}
}