Guest User

Untitled

a guest
Feb 16th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. import java.util.Arrays;
  2.  
  3. public class Test {
  4.     public static void main(String[] args) {
  5.         String input = "67 3 55 69 90 5 100 62 7 1 49 84 87 62 50 84 36 5 40 3 72 9 81";
  6.         int[] numbers = Arrays.stream(input.split(" "))
  7.                               .mapToInt(Integer::parseInt)
  8.                               .sorted()
  9.                               .distinct()
  10.                               .toArray();
  11.         for (int num1 : numbers) {
  12.             for (int num2 : numbers) {
  13.                 for (int num3 : numbers) {
  14.                     if (num1 - num2 == num3 && num1 != num2 && num2 != num3 && num1 != num3) {
  15.                         System.out.println(String.format("%d - %d = %d", num1, num2, num3));
  16.                     }
  17.                 }
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment