#include /* * Check if two queens (row1,col1) and (row2,col2) attack each other. * * Two pieces are on the same diagonal if * the difference of their rows == +- difference of their columns * */ int attack(int row1, int col1, int row2, int col2) { return(row2 == row1 || col1 == col2 || abs(row2 - row1) == abs(col1 - col2)); }