Skip to content

Commit bdc784c

Browse files
committedOct 21, 2020
boj 6603 로또
1 parent 987ba04 commit bdc784c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
 

‎백트래킹/6603.c

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <stdio.h>
2+
3+
int list[13], ans[6];
4+
int N, index;
5+
6+
void dfs(int v) {
7+
if (index == 6) {
8+
for (int i = 0; i < index; i++) {
9+
printf("%d ", ans[i]);
10+
}
11+
printf("\n");
12+
return;
13+
}
14+
15+
for (int i = v; i < N; i++) {
16+
ans[index++] = list[i];
17+
dfs(i + 1);
18+
index--;
19+
}
20+
}
21+
22+
int main() {
23+
while (1) {
24+
scanf("%d", &N);
25+
if (!N) break;
26+
27+
for (int i = 0; i < N; i++) {
28+
scanf("%d", &list[i]);
29+
}
30+
31+
dfs(0);
32+
printf("\n");
33+
index = 0;
34+
}
35+
36+
return 0;
37+
}

0 commit comments

Comments
 (0)
Please sign in to comment.