diff --git a/main.cpp b/main.cpp index 9a3c53b..ca40a95 100644 --- a/main.cpp +++ b/main.cpp @@ -156,7 +156,7 @@ bool isValidPlayer(char c) { return c >= 'A' && c <= 'Z' && c != 'X'; } -Moves serialize(const string &s) { +Moves serialize(char *s) { Moves result; istringstream iss(s); iss >> result.x >> result.y; @@ -227,75 +227,35 @@ void deallocBoard(char **board, int x) { } void printBoard(char **board, int x, int y) { - int boardX = x + 2; - int boardY = y + 2; - myVec > ans(boardX); - - for (int i = 0; i < boardX; ++i) { - ans[i] = myVec(boardY); - for (int j = 0; j < boardY; ++j) { - ans[i][j] = " "; + pt " "; + for (int col = 0; col < y; ++col) { + if (!(col % 10)) { + pt (col / 10); + } else { + pt " "; } } + pt endl; - for (int i = 0; i < y; ++i) { - if (!(i % 10)) { - ans[0][i] = toString((i / 10)); - } - ans[1][i] = toString((i % 10)); + pt " "; + for (int col = 0; col < y; ++col) { + pt (col) % 10; } + pt endl; - for (int i = 0; i < x; ++i) { - if (!(i % 10)) { - ans[i + 2][0] = toString((i / 10)); + // Print the board with row numbers + for (int row = 0; row < x; ++row) { + if (row % 10 == 0) { + pt row / 10; + } else { + pt " "; } - ans[i + 2][1] = toString((i % 10)); + pt row % 10 << " "; + for (int col = 0; col < y; ++col) { + pt board[row][col]; + } + pt endl; } - - for (int i = 0; i < x; ++i) { - for (int j = 0; j < y; ++j) { - ans[i + 2][j + 2] = string(1, board[i][j]); - } - } - - // Calculate the maximum length of the row numbers plus two spaces - 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); - } - - // Print the first two rows with the calculated spaces - for (int i = 0; i < 2; ++i) { - for (int j = 0; j < maxLength; ++j) { - pt ' '; - } - for (int j = 0; j < y; ++j) { - if (!j) { - pt ' '; - } - pt ans[i][j]; - } - pt nl; - } - - // Print the rest of the board - for (int i = 2; i < boardX; ++i) { - for (int j = 0; j < boardY; ++j) { - if (j == 2) { - pt ' '; - } - pt ans[i][j]; - if (!j) { - pt ' '; - } - } - pt nl; - } - pt std::endl; } char toLowerCase(char c) {