Skip to content

anonymous /gist:5db8938f96265860ca76 secret

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#include <iostream>
#include <string>
using namespace std;
const int BOARD_MAX = 10;
const int BOARD_MIN = 3;
bool sizecheck(int);
void displayBoard(char [][BOARD_MAX], int);
int main(void)
{
int boardsize;
char grid[BOARD_MAX][BOARD_MAX];
cout << "Please enter the size of the board (" << BOARD_MIN << " - " << BOARD_MAX << "): ";
cin >> boardsize;
if ((sizecheck(boardsize)) == false)
{
do
{
cout << "Must be a number between " << BOARD_MIN << " and " << BOARD_MAX << ". Try again." << endl;
cout << "Please enter the size of the board (" << BOARD_MIN << " - " << BOARD_MAX << "): ";
cin >> boardsize;
sizecheck(boardsize);
}
while ((sizecheck(boardsize)) == false);
}
grid[0][0] = 'a';
displayBoard(grid, boardsize);
return 0;
}
bool sizecheck(int fboardsize)
{
if ((fboardsize > BOARD_MAX) || (fboardsize < BOARD_MIN))
{
return false;
}
else
{
return true;
}
}
void displayBoard(char fgrid[][BOARD_MAX], int fboardsize)
{
int i, j;
for (i = 0; i < fboardsize; i++)
{
for (j = 0; j < fboardsize; j++)
{
cout << fgrid[i][j];
}
cout << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.