//Some C code for computing the number of conflicts on a board: //h: the number of conflicts //width: the width of the chessboard //position[i]: the position of the queen in the ith column; position[i]==-1 means that there is no queen in the ith column. int replacement[8][2]={{1,2},{1,-2},{-1,2},{-1,-2}, {2,1}, {2,-1}, {-2,1}, {-2,-1}}; int xi, yi, xj, yj; h = 0; for (int i=0; i=0 && position[j]>=0) { xj = j; yj = position[j]; xi = i; yi = position[i]; for (int start=0; start<8; start++) { if (xi-xj==replacement[start][0] && yi-yj==replacement[start][1]) h++; } if (xi-xj==yi-yj|| xi-xj==yj-yi) h++; } }