Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int[] numbers = Arrays
- .stream(scanner.nextLine().split(" "))
- .mapToInt(Integer::parseInt)
- .toArray();
- int difference = Integer.parseInt(scanner.nextLine()),
- count = 0;
- for (int i = 0; i < numbers.length; i++) {
- for (int j = i; j < numbers.length; j++) {
- if (Math.abs(numbers[i] - numbers[j]) == difference) {
- count++;
- }
- }
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement