(int[] arr, int x)
| 50 | public class PairSum { |
| 51 | |
| 52 | public static int pairSum(int[] arr, int x) { |
| 53 | int count = 0; |
| 54 | for (int i = 0; i < arr.length; i++) { |
| 55 | for (int j = i + 1; j < arr.length; j++) { |
| 56 | int sum; |
| 57 | sum = arr[i] + arr[j]; |
| 58 | if (sum == x) { |
| 59 | count += 1; |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | return count; |
| 64 | } |
| 65 | |
| 66 | public static int[] takingInput() { |
| 67 | Scanner sc = new Scanner(System.in); |