#include int result[] = {0, 0, 0, 0, 0, 0, 0, 0, 0 }; void napisReseni() { int i; for (i = 1; i < 9;i++) { printf("%d ",result[i]); } printf("\n"); } int otestuj(int c, int r) { int col = c; int row = r; if (row == 1) return 1; int plus = 1; int tmp = 0; int i = row - 1; while (i > 0) { if (col == result[i]) return 0; tmp = col + plus; if (tmp == result[i]) return 0; tmp = col - plus; if (tmp == result[i]) return 0; plus = plus + 1; i = i - 1; } return 1; } void init(int c, int r) { int col = c; int row = r; int tst = otestuj(col,row); if (tst == 0) return; result[row] = col; if (row == 8) { napisReseni(); return; } int dalsi = row + 1; init(1,dalsi); init(2,dalsi); init(3,dalsi); init(4,dalsi); init(5,dalsi); init(6,dalsi); init(7,dalsi); init(8,dalsi); } void runit() { init(0,0); } main() { runit(); }