Repository navigation
Expand file tree
/
Copy pathBOJ_6603.java
More file actions
57 lines (47 loc) · 1.38 KB
/
Copy pathBOJ_6603.java
File metadata and controls
57 lines (47 loc) · 1.38 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
package baekjoon.silver;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class BOJ_6603 {
static int n;
static int[] arr;
static boolean[] check;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
// 풀이 nCr
while (true) {
st = new StringTokenizer(br.readLine());
// 종료
n = Integer.parseInt(st.nextToken());
if (n == 0) {
break;
}
// 입력
arr = new int[n];
check = new boolean[n];
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
combination(0, 0);
System.out.println();
}
}
public static void combination(int index,int count) {
if (count == 6) {
for (int i = 0; i < n; i++) {
if(check[i]) {
System.out.print(arr[i] + " ");
}
}
System.out.println();
return;
}
for (int i = index; i < n; i++) {
check[i] = true;
combination(i+1, count+1);
check[i] = false;
}
}
}