Checss board

Hello I need help writing a program that repeated shows all possible moves of a queen or a knight in a chess game. The board will be 8 x 8 array of characters.
k- knight
q - queen
Knight has 8 possible moves

void move_queen (char board [8][8], int row, int col)
laces the queen, Q on the board at the qiven row and column and places * characrters in all aquares where the queen can legally move.

void move_knight (char board [8][8], int row, int col)
laces the queen,K on the board at the qiven row and column and places * characrters in all aquares where the queen can legally move.

I have this so far and I am losted and puzzled


#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;

void init_board (char board [8][8]);
void move_queen (char board [8][8], int row, int col);
void move_knight (char board [8][8], int row, int col);
void print_board (char board [8][8]);

int main(int argc, char *argv[])
{
char board [8][8];
int row, col;
char piece, q, k, e;



cout <<"Enter q (queen), k (knight) or e (end): ";
cin >> piece;

cout <<"\nEnter starting row: ";
cin >> row;

cout <<"Enter starting column: ";
cin >> col;

init_board (board);

move_queen (board, row, col);
move_knight (board, row, col);
print_board (board);


system("PAUSE");
return EXIT_SUCCESS;
}

void init_board (char board [8][8])
{
int row, col;


for (row = 0; row < 8; row++)
for (col = 0; col < 8; col++)
{
board [row][col] = '*';

}
}
void move_queen (char board [8][8], int row, int col)
{
int r, c;

for (r = row + 1 ; r < 8; r++)
{
for (c = 0; c < 8; c++)
{
board [row][col] = 'Q';
}
}
}
void move_knight (char board [8][8], int row, int col)
{
int r, c;

for (r = row + 1, c = col + 1; r < 8
&& c < 8; r++, c++)
{
board [row][col] = 'K';
} }
void print_board (char board [8][8])
{
int r, c;

for (r = 0; r < 8; r++)
for (c = 0; c < 8; c++)

cout << "\n" << board [r][c];
cout <<endl;
}

Topic archived. No new replies allowed.