-
-
Save anonymous/32c3af6b37d427b40a92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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