We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 987ba04 commit bdc784cCopy full SHA for bdc784c
백트래킹/6603.c
@@ -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
33
+ index = 0;
34
35
36
+ return 0;
37
0 commit comments