/*************************************************************** * THE PROBLEM OF CHESS KNIGHT * * ------------------------------------------------------------ * * A question, in chess game, is to know wether a knight can * * go through all the board squares passing only once on each * * square. The answer is yes for a 8 x 8 board, as this small * * program shows. We use here the law givan by Warnsdorff in * * 1823 that almost always allows finding a solution: * * "In each strike, you must play the knight to the square from * * which there are the less exits towards the squares not yet * * full." * * ------------------------------------------------------------ * * After "Graphisme dans le plan et dans l'espace avec Turbo * * Pascal 4.0 de R. Dony - MASSON 1990 page 227". * * * * C++ Release in API style By J-P Moreau, Paris. * ***************************************************************/ #include #include #include #include HDC hdc; RECT rect; HPEN hpen; //"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