diff options
| author | 2025-12-13 19:21:04 +0100 | |
|---|---|---|
| committer | 2025-12-13 19:21:04 +0100 | |
| commit | e51ac7ec7d3e32e1771c9f824da3dc7e4dcd2bc5 (patch) | |
| tree | a0b7a0c29247374b96fdbfb29bc365d15e9e36a5 /test/external/c-testsuite/tests/single-exec/00040.c | |
| parent | 6c7cdc537b7b341f9ca25a3e8b61de46c99840e7 (diff) | |
add c-testsuite
Diffstat (limited to 'test/external/c-testsuite/tests/single-exec/00040.c')
| -rw-r--r-- | test/external/c-testsuite/tests/single-exec/00040.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/external/c-testsuite/tests/single-exec/00040.c b/test/external/c-testsuite/tests/single-exec/00040.c new file mode 100644 index 0000000..819dc9c --- /dev/null +++ b/test/external/c-testsuite/tests/single-exec/00040.c @@ -0,0 +1,55 @@ +#include <stdlib.h> + +int N; +int *t; + +int +chk(int x, int y) +{ + int i; + int r; + + for (r=i=0; i<8; i++) { + r = r + t[x + 8*i]; + r = r + t[i + 8*y]; + if (x+i < 8 & y+i < 8) + r = r + t[x+i + 8*(y+i)]; + if (x+i < 8 & y-i >= 0) + r = r + t[x+i + 8*(y-i)]; + if (x-i >= 0 & y+i < 8) + r = r + t[x-i + 8*(y+i)]; + if (x-i >= 0 & y-i >= 0) + r = r + t[x-i + 8*(y-i)]; + } + return r; +} + +int +go(int n, int x, int y) +{ + if (n == 8) { + N++; + return 0; + } + for (; y<8; y++) { + for (; x<8; x++) + if (chk(x, y) == 0) { + t[x + 8*y]++; + go(n+1, x, y); + t[x + 8*y]--; + } + x = 0; + } + return 0; +} + +int +main() +{ + t = calloc(64, sizeof(int)); + go(0, 0, 0); + if(N != 92) + return 1; + return 0; +} + |