![]() Now to set the top-left square to a value of 1 you would do something like this: board = 1 You could use a 2D array to represent it like so: char board Tic-Tac-Toe consists of a 3x3 playing space. Reset board if user wants to play again What type of array do I use? And I am also assuming that the bulk of the code (checking for valid moves, checking for wins, etc.) will change. ![]() I would like to use arrays but although I understand its concept, I am having difficulty in figuring out how to implement it. This means that there is a lot of repetitive code. However the program does not utilise arrays to hold the moves but uses char variables. This is a hot mess! Consider what you actually need to do here.I've written (with a bit of help) a tic tac toe program. ![]() This could have been much simpler if you used X, O and for the symbols instead of 1, -1, and a zero. System("CLS") will only work on Windows, you can find some alternatives here. The only thing C++ about this is the use of std::vector instead of int and std::cout instead of printf. This looks like it started life as C code. Now for the bad, and unfortuanatly there is quite a bit.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |