old
(HH)

Basic idea:

//

// n -- the number of non-attacked compoments already in the grid

// _ -- space

//

components(n)

{

__while (There is an empty cell (say C) in the grid where

_________the n+1th compoment may (or may not) be put

_________in a non-attacked manner) {

____Selects the cell C and tests if it is non-attacked.

____if (The cell C is non-attacked) {

______Puts the n+1th component into the cell C.

______if (n + 1 == 8 (the maximum number of components))

________Output the results (Gets one of the solutions).

______else

________Calls components(n + 1)

______Removes the n+1th compoment from the cell C

______(Tries the next empty cell).

____}

__}

__return

}

//

// n -- the number of non-attacked compoments already in the grid

// _ -- space

//

components(n)

{

__while (There is an empty cell (say C) in the grid where

_________the n+1th compoment may (or may not) be put

_________in a non-attacked manner) {

____Selects the cell C and tests if it is non-attacked.

____if (The cell C is non-attacked) {

______Puts the n+1th component into the cell C.

______if (n + 1 == 8 (the maximum number of components))

________Output the results (Gets one of the solutions).

______else

________Calls components(n + 1)

______Removes the n+1th compoment from the cell C

______(Tries the next empty cell).

____}

__}

__return

}

(#62137@0)

2001-5-6 -05:00

2001-5-6 -05:00