Skip to content

Instantly share code, notes, and snippets.

/game v2 Secret

Created January 31, 2014 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/32c3af6b37d427b40a92 to your computer and use it in GitHub Desktop.
Save anonymous/32c3af6b37d427b40a92 to your computer and use it in GitHub Desktop.
#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 + 1][BOARD_MAX + 1];
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[][BOARD_MAX], 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