// dama.cpp #include "stdafx.h" #include <iostream> #include <string> using namespace std; const int N = 8; int pole[N]; int pocet = 0; void vypis(){ cout << pocet <<": "; for(int i=0;i<N;i++){ cout << pole[i] << ", "; } cout << endl; }; void vypissach(){ for (int k=0;k<N;k++){ for(int i=0;i<N;i++){ char c = '.'; if (pole[i] == k) c = 'O'; cout << c << " "; } cout << endl; } cout << endl; system ("pause"); }; void umisti(int j){ for(int i=0;i<N;i++) { bool ok = true; for(int k=1; k<=j && ok; k++){ int h=pole[j-k]; if ( h==i || h-k == i || h+k == i) ok=false; } if (ok) { pole[j]=i; if(j<N-1) umisti(j+1); else { pocet = pocet +1; vypis(); } } } } int _tmain(int argc, _TCHAR* argv[]) { umisti(0); system ("pause"); return 0; }