#include "stdafx.h" #include #include using namespace std; const int n = 8; int p[n] ; void umisti (int k) /* k .. cislo sloupce */ { for (int i = 0; i < n; i++) { bool ok = true; for (int d = 1; d <= k; d++) { if (p[k-d] == i || p[k-d] == i-d || p[k-d] == i+d) { ok = false; } } if (ok) { p[k] = i; if (k < n - 1) umisti (k + 1); else { for (int l = 0; l < n; l++) cout << p[l] << " "; cout << endl; } } } } int main () { for (int k = 0; k < n; k++) p[k] = -1; umisti (0); // for (int k = 0; k < n; k++) cout << p[k] << " "; // cout << endl; cout << "Konec programu" << endl; system ("pause"); return 0; }