fix printBoard index

This commit is contained in:
Sandipsinh Rathod 2024-10-11 13:47:55 -04:00
parent 3cbb9989c6
commit 3d9ddad0b6
No known key found for this signature in database

@ -246,10 +246,10 @@ void printBoard(char **board, int x, int y) {
int maxLength = 0;
for (int i = 0; i < x; ++i) {
int length = 2 + (i >= 10 ? 2 : 1);
for(int j = 0; j < y; ++j) {
length = max(length, (int)ans[i + 2][j + 2].size());
}
maxLength = max(maxLength, length);
for (int j = 0; j < y; ++j) {
length = max(length, (int) ans[i + 2][j + 2].size());
}
maxLength = max(maxLength, length);
}
// Print the first two rows with the calculated spaces
@ -258,6 +258,9 @@ void printBoard(char **board, int x, int y) {
pt ' ';
}
for (int j = 0; j < y; ++j) {
if (!j) {
pt ' ';
}
pt ans[i][j];
}
pt nl;
@ -266,7 +269,7 @@ void printBoard(char **board, int x, int y) {
// Print the rest of the board
for (int i = 2; i < boardX; ++i) {
for (int j = 0; j < boardY; ++j) {
if (j==2) {
if (j == 2) {
pt ' ';
}
pt ans[i][j];