-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path로또.java
More file actions
43 lines (37 loc) · 1.22 KB
/
로또.java
File metadata and controls
43 lines (37 loc) · 1.22 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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
static int k;
static int[] numbers, seleted;
static StringBuilder sb = new StringBuilder();
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while(true){
StringTokenizer st = new StringTokenizer(br.readLine());
k = Integer.parseInt(st.nextToken());
if(k == 0) break;
numbers = new int[k];
seleted = new int[6];
for (int i = 0; i < k; i++) {
numbers[i] = Integer.parseInt(st.nextToken());
}
combi(0, 0);
sb.append("\n");
}
System.out.println(sb);
}
static void combi(int start, int cnt){
if(cnt == 6){
for (int i = 0; i < 6; i++)
sb.append(seleted[i]).append(" ");
sb.append("\n");
return;
}
for (int i = start; i < k; i++) {
seleted[cnt] = numbers[i];
combi(i + 1, cnt + 1);
}
}
}