lr11 -> task_1 -> e1
This commit is contained in:
21
lr11/task_1/e1.java
Normal file
21
lr11/task_1/e1.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package lr11.task_1;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class e1 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
System.out.println("Введите числа через пробел:");
|
||||||
|
String input = scanner.nextLine();
|
||||||
|
|
||||||
|
int[] result = Arrays.stream(input.split("\\s+"))
|
||||||
|
.mapToInt(Integer::parseInt)
|
||||||
|
.filter(n -> n % 2 == 0)
|
||||||
|
.toArray();
|
||||||
|
|
||||||
|
System.out.println("Result:");
|
||||||
|
System.out.println(Arrays.toString(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user