-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterview.java
More file actions
42 lines (38 loc) · 1022 Bytes
/
Copy pathInterview.java
File metadata and controls
42 lines (38 loc) · 1022 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
34
35
36
37
38
39
40
41
42
import java.awt.*;
import java.util.Random;
public class Interview {
public static void main (String args[]) {
// Declare int array of size 10
int array[] = new int[10];
// Random rando = new Random();
/*
for (int x = 0; x < 10; x++) {
array[x] = rando.nextInt(99) + 1;
System.out.println (array[x]);
}
*/
// Initialize array
array[0] = 5;
array[1] = 30;
array[2] = 90;
array[3] = 12;
array[4] = 60;
array[5] = 70;
array[6] = 9;
array[7] = 7;
array[8] = 1;
array[9] = 0;
// Iteratre through I and J
for (int i = 0; i < array.length; i++) {
for (int j = i+1; j < array.length; j++) {
// Store values at index i and j
int iVal = array[i];
int jVal = array[j];
// Check for pairs
if (iVal + jVal == 100) {
System.out.println (iVal + " + " + jVal + " = 100!");
}
}
}
}
}