-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArray42.java
More file actions
33 lines (32 loc) · 809 Bytes
/
Array42.java
File metadata and controls
33 lines (32 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package array;
/**
* Project Admin -> Husanboy Azamov
* Package Name -> array
* Class Name -> Array42
* Copyright © : 6/24/2022
*/
public class Array42 {
public static void main(String[] args) {
array42(new int[]{25, 4, 14, 16, 5, 15}, 10);
}
public static void array42(int[] array, int r) {
int min = Integer.MAX_VALUE;
int k = 0;
int na = 0;
int son1 =0;
int son2 =0;
int n = 0;
for (int i = 1; i < array.length; i++) {
na = array[k] + array[i];
n = Math.abs(na - r);
if (min > n) {
min = n;
son1=array[k];
son2=array[i];
}
k++;
}
System.out.println(son1);
System.out.println(son2);
}
}