I have read a bit of codes from Sircool and DC a.
Sircool wrote his codes in a Turkish language. While 'DC a' wrote something that is logically sensible: I noticed that it doesn't build and run well in CODE:BLOCKS. I just hope that someone will guide me in the right direction here.
---------------------------------------------------------
Sircool wrote his codes in a Turkish language. While 'DC a' wrote something that is logically sensible: I noticed that it doesn't build and run well in CODE:BLOCKS. I just hope that someone will guide me in the right direction here.
---------------------------------------------------------
Code:
//Main.cpp: 'DC a' defines the entry point for the console application
int solve (int chess_board[][], int last_col, int last_row, int count)
{
if (count == 64)
{
//print the entire chess board;
//stopping cas
}
// up 2, left 1 case
if((last_row > 1) && (last_col > 0))
{
if(chess_board[last_col-1] [last_row-2] == 0) // not occupied
{
chess_board[last_col-1] [last_row-2] = count;
solve(&chess_board, last_col, last_row-2, count=1);
chess_board[last_col-1] [last_row-2] = 0
}
}
//similarly for the other seven possibilities
}
int main ()
{
for each row (0 - 7)
{
for each col (0 - 7)
{
chess_board[col] [row] = 1
solve (&chess_board, col, row, 1);
chess_board[row] [col] = 0;
}
}
system ("PAUSE");
return EXIT_SUCESS;
}
Comment