diff --git a/main.cpp b/main.cpp index ca40a95..cb35210 100644 --- a/main.cpp +++ b/main.cpp @@ -17,9 +17,11 @@ struct myPair { T1 first; T2 second; - myPair() : first(), second() {} + myPair() : first(), second() { + } - myPair(const T1 &first, const T2 &second) : first(first), second(second) {} + myPair(const T1 &first, const T2 &second) : first(first), second(second) { + } }; // -------- END PAIR IMPL -------- @@ -60,6 +62,7 @@ string toString(int x) { int max(int a, int b) { return a > b ? a : b; } + // -------- END HELPER FUNCTIONS -------- // -------- START RAII HELPERS-------- @@ -111,6 +114,7 @@ public: myVec() { capacity = 0; length = 0; + data = NULL; } myVec(size_t size) { @@ -284,7 +288,7 @@ void bubbleSort(myPair > *a) { void printScores(int *points, char blacklist) { myPair > *arr = static_cast > *>(alloc( - 26 * sizeof(myPair >))); + 26 * sizeof(myPair >))); for (int i = 0; i < 26; i++) { myPair > p; @@ -316,10 +320,10 @@ void printScores(int *points, char blacklist) { for (int i = 25; i > -1; i--) { if (arr[i].second.first != -1) { pt "Player " << arr[i].first << " has " << arr[i].second.first << " boxes" << ( - (i == 25 || arr[i].second.second) && arr[i].first != blacklist + (i == 25 || arr[i].second.second) && arr[i].first != blacklist ? arr[i].second.second - ? " (tie)\n" - : " (win)\n" + ? " (tie)\n" + : " (win)\n" : nl); } } @@ -333,11 +337,11 @@ bool isValidMove(int x, int y, char **board) { } void addPoint( - int *points, - char **board, - int x, - int y, - char player + int *points, + char **board, + int x, + int y, + char player ) { if (board[x][y] == ' ') { if (points[normalize(player)] == -1) { @@ -350,13 +354,13 @@ void addPoint( } void solveVertical( - int moveX, - int moveY, - char **board, - int *points, - int x, - int y, - char player + int moveX, + int moveY, + char **board, + int *points, + int x, + int y, + char player ) { // TODO: fix ambiguity: // - @@ -384,12 +388,12 @@ void solveVertical( } void solveHorizontal( - int moveX, - int moveY, - char **board, - int *points, - int y, - char player + int moveX, + int moveY, + char **board, + int *points, + int y, + char player ) { if (moveY) { if (moveY == y - 1) { @@ -409,7 +413,7 @@ void solveHorizontal( } } else { if (board[moveX][moveY + 2] != ' ' && (board[moveX + 1][moveY + 1] != ' ' && board[moveX - 1][moveY + 1] != - ' ')) { + ' ')) { addPoint(points, board, moveX, moveY + 1, player); } }