#include #include #define n 4 #define true 1 #define false 0 typedef int bool; int col[100] = { 0, }; int count = 0; bool promising(int i); void Rsult(); void queens(int i); void main(){ queens(0); } void Result() { int i; printf("´äÀº : "); for (i = 1; i <= n; i++){ printf("<%d,%d> ", i, col[i]); } printf("\n °ÅÃÄ°£ ³ëµå Ƚ¼ö :%d ", count); printf("\n"); return; } void queens(int i) { int j; count++; if (promising(i)) { if (i == n)Result(); else for (j = 1; j <= n; j++) { col[i + 1] = j; queens(i + 1); } } } bool promising(int i) { int k = 1; bool switch_ = true; while (k < i && switch_) { if (col[i] == col[k] || abs(col[i] - col[k]) == i - k) switch_ = false; k++; } return switch_; }