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