The part in is_attaced in which you check the diagonals is not working. It has two basic problems, first you dont check all diagonals all rows – you just check the previous row. And, second, you are doing out of bound accesses, when you are in the first or last column.
An implementation that is not realy efficient but easy to understand check the both diagonals seperately
for( int i=min(col, row); i>0;i-- )
{
if( board[row-i][col-i]==1 )
return true;
}
for( int i=MAX_COL; i>row;i-- )
{
if( board[row-i][col+i]==1 )
return true;
}
A better way would be doing both in one loop.
1
solved N-Queens Algorithm using c++