Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class Exc08MagicSum {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int[] input = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
- int n = scanner.nextInt();
- for (int i = 0; i < input.length; i++) {
- for (int j = i + 1; j < input.length; j++) {
- if (input[i] + input[j] == n) {
- System.out.println(input[i] + " " + input[j]);
- }
- }
- }
- }
- }
- /*
- * Write a program, which prints all unique pairs in an array of integers whose sum is equal to a given number.
- * */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement