// Kun.cpp #include "stdafx.h" #include <iostream> #include <string> using namespace std; const int N=8; int pole [N][N]; void pohyb(int krok, int x, int y) { if (0<=x && x<N && 0<=y && y<N ){ if (pole [x][y]>krok || pole [x][y]==-1){ pole [x][y]=krok; pohyb(krok+1,x+2, y+1); pohyb(krok+1,x-2, y+1); pohyb(krok+1,x-2, y-1); pohyb(krok+1,x+2, y-1); pohyb(krok+1,x+1, y+2); pohyb(krok+1,x+1, y-2); pohyb(krok+1,x-1, y+2); pohyb(krok+1,x-1, y-2); } } } int _tmain(int argc, _TCHAR* argv[]) { for (int i=0;i<N;i++) for (int j=0; j<N; j++) pole [i][j]=-1; pohyb (0, 0, 0); for (int i=0;i<N;i++){ for (int j=0; j<N; j++) if (pole [i][j] == -1) cout << ". "; else cout << pole [i][j]<< " "; cout<<endl;} cout << "Hotovo" << endl; system ("pause"); return 0; }