Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- public class Test {
- public static void main(String[] args) {
- 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";
- int[] numbers = Arrays.stream(input.split(" "))
- .mapToInt(Integer::parseInt)
- .sorted()
- .distinct()
- .toArray();
- for (int num1 : numbers) {
- for (int num2 : numbers) {
- for (int num3 : numbers) {
- if (num1 - num2 == num3 && num1 != num2 && num2 != num3 && num1 != num3) {
- System.out.println(String.format("%d - %d = %d", num1, num2, num3));
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment