- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogrammers77484.java
More file actions
Latest commit
93 lines (87 loc) · 2.37 KB
/
Copy pathprogrammers77484.java
File metadata and controls
93 lines (87 loc) · 2.37 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
packageProgrammers;
importjava.util.ArrayList;
importjava.util.Arrays;
importjava.util.Scanner;
importjava.util.StringTokenizer;
publicclassprogrammers77484 {
publicstaticvoidmain(String[] args) {
Solution77484sc = newSolution77484();
Scannerin = newScanner(System.in);
StringTokenizerstr = newStringTokenizer(in.nextLine(), ", ");
int[] lottos = newint[6];
for (inti = 0; i < 6; i++) {
lottos[i] = Integer.parseInt(str.nextToken());
}
int[] win_nums = newint[6];
str = newStringTokenizer(in.nextLine(), ", ");
for (inti = 0; i < 6; i++) {
win_nums[i] = Integer.parseInt(str.nextToken());
}
System.out.println(sc.solution(lottos, win_nums));
}
}
classSolution77484 {
publicint[] solution(int[] lottos, int[] win_nums) {
Arrays.sort(lottos);
Arrays.sort(win_nums);
ArrayListmatch = newArrayList<>();
intcount = 0;
inthigh = 0;
intlow = 0;
for (inti = 0; i < 6; i++) {
if (lottos[i] == 0)
count++;
}
for (inti = 0; i < 6; i++) {
for (intj = 0; j < 6; j++) {
if (lottos[i] == win_nums[j])
match.add(lottos);
}
}
switch (match.size() + count) {
case6:
high = 1;
break;
case5:
high = 2;
break;
case4:
high = 3;
break;
case3:
high = 4;
break;
case2:
high = 5;
break;
default:
high = 6;
break;
}
switch (match.size()) {
case6:
low = 1;
break;
case5:
low = 2;
break;
case4:
low = 3;
break;
case3:
low = 4;
break;
case2:
low = 5;
break;
default:
low = 6;
break;
}
int[] answer = {high, low};
for (inti = 0; i < answer.length; i++) {
System.out.println(answer[i]);
}
returnanswer;
}
}