If you want to shorten the code, how about moving these duplicated lines out of the switch statement?:Oh and guess what, then using a simple break will have the desired effect of actually breaking out of the loop!Code:if (board[i][j + 1] != '.' && board[i + 1][j] != '.' && board[i - 1][j] != '.' && board[i][j - 1] != '.')
k = 27;
Here's another tip:if you increment j before this line, then you wont have to add one to j inside the []:Do the same kind of thing inside each case and then, surprise surprise, all four cases would have the same line of code just using board[i][j]. Once again we move that line of code out of the switch statement.Code:board[i][j +1] = letters[k]; //move right
Waiting for the "OMG it's so much shorter now!". But wait, there's still more. Sooner or later it will be short enough to spot the bug amoung the few lines remaining.