Skip to content

Instantly share code, notes, and snippets.

@RMuskovets
Last active December 7, 2019 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RMuskovets/ecfd63f29332d2c99f9312ace0b12a79 to your computer and use it in GitHub Desktop.
Save RMuskovets/ecfd63f29332d2c99f9312ace0b12a79 to your computer and use it in GitHub Desktop.
Решение задачи JavaRush Java Core ур3 лекция 11 - Сортировка четных чисел из файла
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;
public class Solution {
public static void main(String[] args) throws Exception {
Files.readAllLines(Paths.get(new Scanner(System.in).nextLine())).stream()
.mapToInt(Integer::parseInt) // String -> int
.filter(x -> x % 2 == 0) // лишаем только четные
.sorted() // сортируем
.forEach(System.out::println); // выводим на экран
}
}
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;
public class Solution {
public static void main(String[] args) throws Exception {
Files.readAllLines(Paths.get(new Scanner(System.in).nextLine())).stream().mapToInt(Integer::parseInt).filter(x -> x % 2 == 0).sorted().forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment