/************************************************************* * Chess: Problem of the Eight Queens * * ---------------------------------------------------------- * * Description: * * This famous problem consists in finding locations of eight * * queens on a chess board, such as no one can be taken by * * another one. After Arthur Engel Cedic (1979), this problem * * was posed for the first time in 1848 by Max Bezzel in a * * Chess Journal. This publication gave way to an extraordi- * * nary passion and on sept. 21th, 1850 a certain Dr Nauck * * gave all the solutions when the famous mathematician Gauss * * had only found 72 out of 92. But it is true that he had * * better to attend to... This small program gives all the * * solutions from n=4 to n=8 (size of board) by using the so * * called "backtracking method". * * ---------------------------------------------------------- * * REFERENCE: * * "Graphisme dans le plan et dans l'espace avec Turbo Pascal * * 4.0 By R. Dony - MASSON, Paris 1990". * * * * C++ Release in API style By J-P Moreau, Paris. * *************************************************************/ #include #include #include #include HDC hdc; RECT rect; HPEN hpen, hpenOld; //"home made" graphic commands for hdc environment used by above functions void DrawPixel(int ix,int iy) { //sorry, no other available command found Rectangle(hdc,rect.left+ix,rect.top+iy, rect.left+ix+2,rect.top+iy+1); } void Swap(int *i1,int *i2) { int it; it=*i1; *i1=*i2; *i2=it; } void DrawLine(int ix1,int iy1,int ix2,int iy2) { int i,il,ix,iy; float dx,dy; if (ix2