struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / qct / 0041-queen.c
blob2cb39e6a4ce48207732b317263f55135d77cf6c0
2 int *calloc(int, int);
4 int N;
5 int *t;
7 int
8 chk(int x, int y)
10 int i;
11 int r;
13 for (r=i=0; i<8; i++) {
14 r = r + t[x + 8*i];
15 r = r + t[i + 8*y];
16 if (x+i < 8 & y+i < 8)
17 r = r + t[x+i + 8*(y+i)];
18 if (x+i < 8 & y-i >= 0)
19 r = r + t[x+i + 8*(y-i)];
20 if (x-i >= 0 & y+i < 8)
21 r = r + t[x-i + 8*(y+i)];
22 if (x-i >= 0 & y-i >= 0)
23 r = r + t[x-i + 8*(y-i)];
25 return r;
28 int
29 go(int n, int x, int y)
31 if (n == 8) {
32 N++;
33 return 0;
35 for (; y<8; y++) {
36 for (; x<8; x++)
37 if (chk(x, y) == 0) {
38 t[x + 8*y]++;
39 go(n+1, x, y);
40 t[x + 8*y]--;
42 x = 0;
46 int
47 main()
49 t = calloc(64, sizeof(int));
50 go(0, 0, 0);
51 if(N != 92)
52 return 1;
53 return 0;