-
Notifications
You must be signed in to change notification settings - Fork 1
/
Test001.java
36 lines (30 loc) · 866 Bytes
/
Test001.java
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
package testPractice;
import java.util.*;
public class Test001 {
public static void main(String[] args) {
int arr[] = {5,9,7,10};
int cnt = 0;
int divisor = 5;
List<Integer> temp = new ArrayList<Integer>();
for(int i =0 ; i<arr.length;i++){
if((arr[i]%divisor) == 0 ){
temp.add(arr[i]);
cnt++;
System.out.println("cnt : " +cnt);
}
}
int answer[] = new int[temp.size()];
for(int i =0 ; i < temp.size(); i++){
answer[i] = temp.get(i);
}
int idx = temp.indexOf(5);
System.out.println(idx);
Arrays.sort(answer);
if(cnt == 0) {
answer[1]=-1;
}
for(int x : answer) {
System.out.println("x : " +x);
}
}
}