1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
const int COL = 17;
const int ROW = 17;
void initializeBoard(char [][COL], int, int);
void displayBoard(char [][COL], int, int);
int main()
{
char board[ROW][COL];
initializeBoard(board, ROW, COL);
displayBoard(board, ROW, COL);
return 0;
}
void initializeBoard(char theBoard [][COL], int row, int col)
{
for(int r = 0; r < ROW; r++)
{
for(int c = 0; c < COL; c++)
{
theBoard[r][c] = '.'; //250
}
}
for(int c = 0; c < COL; c++)
{
theBoard[0][c] = '__'; // 205
theBoard[ROW-1][c] = '__'; //205
}
for(int r = 0; r < row; r++)
{
theBoard[r][0] = '|'; //186
theBoard[r][COL-1] = '|'; //186
}
theBoard[0][0] = ' ' ; //201
theBoard[0][COL-1] = ' '; //187
theBoard[ROW-1][0] = ' '; //200
theBoard[ROW-1][col-1] = ' '; //188
}
//Prints Board
void displayBoard(char theBoard [][COL], int row, int col)
{
for(int r = 0; r < ROW; r++)
{
for(int c = 0; c < COL; c++)
{
cout << theBoard[r][c];// << ' ';
}
cout << endl;
}
}
|