Attachment 'claus.c'
Download 1 #include <stdio.h>
2
3 #define nodes 5
4 #define edges 8
5
6 char edge[nodes][nodes] = {
7 { 0, 1, 0, 1, 1 },
8 { 1, 0, 1, 1, 1 },
9 { 0, 1, 0, 1, 0 },
10 { 1, 1, 1, 0, 1 },
11 { 1, 1, 0, 1, 0 }
12 };
13
14 char path[edges + 2] = "1xxxxxxxx";
15
16 void move(unsigned int i, unsigned int level)
17 {
18 if (level > edges) {
19 printf("%s\n", path);
20 } else {
21 unsigned int j;
22 for (j = 0; j < nodes; ++j) {
23 if (edge[i][j]) {
24 edge[i][j] = 0;
25 edge[j][i] = 0;
26
27 path[level] = '1' + j;
28 move(j, level + 1);
29
30 edge[j][i] = 1;
31 edge[i][j] = 1;
32 }
33 }
34 }
35 }
36
37 int main(void)
38 {
39 move(0, 1);
40 return 0;
41 }
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.