Advertisement
emodev

Magic Sum

Feb 12th, 2019
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. package p03_Arrays.Exercices;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5.  
  6. public class h_MagicSum {
  7.     public static void main(String[] args) {
  8.         Scanner console = new Scanner(System.in);
  9.         int[] ints = Arrays.stream(console.nextLine().split(" "))
  10.                 .mapToInt(Integer::parseInt).toArray();
  11.         int equalNum = Integer.parseInt(console.nextLine());
  12.  
  13.         for (int i = 0; i < ints.length; i++) {
  14.             for (int j = i+1; j < ints.length; j++) {
  15.                 if (ints[i] + ints[j] == equalNum){
  16.                     System.out.println(ints[i] + " " + ints[j]);
  17.                 }
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement