#include "stdafx.h"
 
#include <iostream>
#include <string>
#include <cassert>
using namespace std;
 
const int N=8;
 
int v[N];
int pocet=0;
 
void vypis(){
    for(int i=0; i< N; i++)
        cout << v[i] << " ";
    cout << " ... " << pocet<< endl;
}
 
void vypisSach(){
    for(int j=0; j<N; j++){
        for(int i=0; i<N; i++){
            char c = '.';
            if (v[i]==j)
                c = '*';
            cout << c << " ";
        }
        cout << endl;
    }
    cout << endl;
    char t;
    cin >> t;
}
 
void umisteni(int i){
    for(int j=0; j< N; j++){
        bool ok = true;
        for(int k=1; k<=i && ok; k++){
            int t = v[i-k];
            if ( t==j || t==j+k || t==j-k)
                ok = false;
 
        }
 
        if(ok == true){
            v[i] = j;
            if (i+1<N) umisteni(i+1);
            else 
            {
                pocet++;
                vypis();
            }
 
        }
    }
}
 
 
int _tmain(int argc, _TCHAR* argv[])
{
    umisteni(0);
    system ("pause");
    return 0;
}
 
dama_utery.txt · Last modified: 2017/04/11 10:16 by 147.32.8.115
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki