anonymous / gist:5db8938f96265860ca76 secret
Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:5db8938f96265860ca76
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 60 61 62 63 64 65 66 67 68
#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.