[ create a new paste ] login | about

Link: http://codepad.org/2NV5IvpO    [ raw code | output | fork ]

norbyd189@gmail.com - C, pasted on Sep 14:
#define N 8
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

    bool a[8] = {true};		// 1 to 8
    bool b[16] = {true};        // 2 to 16
    bool c[16] = {true};        // -7 to 7
    int  x[8];                  // 1 to 8

// for i =  1 to  8 do a[ i] = true;
// for i =  2 to 16 do b[ i] = true;
// for i = -7 to  7 do c[ i] = true;

void trythis(int i, bool q)
{
    int j; 

    j = 0;
    do 
    {
        j = j + 1; 
        q = false;
        if (a[ j] and b[ i + j] and c[ i - j]) 
        {
            x[ i    ] = j;
            a[ j    ] = false; 
            b[ i + j] = false; 
            c[ i - j] = false;
            if (i < 8) 
            {
                trythis( i + 1, q);
                if not q 
                {
                    a[ j] = true; 
                    b[ i + j] = true; 
                    c[ i - j] = true;
                }
            } 
            else 
                q = true
            }
    }
    while not q or (j not= 8);
)


void eightqueen1(void);
{ 
	int i;
	bool q;

trythis( 1, q);

if q then
    for (i = 1; i < 9; i++) 
    {
	printf("%4d ", x[ i]);
    }
    printf("\n");
}

int main()	// driver program to test above function
{
    eightqueen1();
 
    return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
In function 'trythis':
Line 25: error: expected ')' before 'and'
Line 34: error: expected '(' before 'not'
Line 34: error: 'not' undeclared (first use in this function)
Line 34: error: (Each undeclared identifier is reported only once
Line 34: error: for each function it appears in.)
Line 43: error: expected ';' before '}' token
Line 45: error: expected '(' before 'not'
Line 46: error: expected statement before ')' token
Line 56: error: expected '(' before 'q'
Line 69: error: expected declaration or statement at end of input


Create a new paste based on this one


Comments: