Question
Using C++ Welcome to the memory game! Look away from the board and have a helper enter r to randomize the board until they have
Using C++
Welcome to the memory game! Look away from the board and have a helper enter r to randomize the board until they have a random board that they like. Then you glance at it and try to imprint it in your mind and look away. Your helper will then select a single piece to be flipped by choosing its row and column. The changed board is then displayed. You then must try to guess which one it was. Enter x to exit the program. 1 2 3 4 5 6 - - - - - - - - A | X X O O X O | A B | X O O O X X | B C | X X O O O X | C D | O X X X X X | D E | X O X X O O | E F | X O X X O O | F - - - - - - - - Enter r to randomize to board, or row and column to change a value -> r 1 2 3 4 5 6 - - - - - - - - A | O X O X X O | A B | O O X O X X | B C | O O X O O O | C D | O X O O O O | D E | O O X O X X | E F | X X O O O X | F - - - - - - - - Enter r to randomize to board, or row and column to change a value -> r 1 2 3 4 5 6 - - - - - - - - A | O X X O X O | A B | O O O X O O | B C | O X O X X O | C D | O O O X O O | D E | O O O X X X | E F | X X O X O O | F - - - - - - - - Enter r to randomize to board, or row and column to change a value -> e1 1 2 3 4 5 6 - - - - - - - - A | O X X O X O | A B | O O O X O O | B C | O X O X X O | C D | O O O X O O | D E | X O O X X X | E F | X X O X O O | F - - - - - - - - What piece do you think it was? -> e1 *** Congratulations, you did it! *** Thank you for playing. Exiting... Notes Your program must use 36 char variables named p0..p35 to represent the board. They must be used in printing the board and in being checked to validate parity. These board characters may be declared globally. The secret to this program is that there are an odd number of Xs in each row and column on the board. This is known as odd parity. When a single position is changed, then the corresponding row and column for that position now have an even number of Xs, thus giving away the position for this single position that is changed. You may not use arrays, or strings, or any other method to circumvent the need to handle fundamentally using the 36 variables throughout your program. Failure to follow this constraint will result in a 20 point deduction. (Hint: Think about how you would write the program if you were using arrays. Consider how you might instead use a function in each location where otherwise you would use an array. If you figure this out, please do not give it away on Piazza.) Input for 'x' to exit, 'r' to randomize, or row letter should be accepted as either upper or lower case. The row letter and column number should be accepted when entered right next to each other as shown in the example above, or separated by a space. Note that your program needs to be able to handle either a single input ('r' or 'x') or two characters of input (e.g. "C5"). To do this you should have a cin statement to read the first character. Then check it. Only if it is not 'r' or 'x' then read a second character using cin. After the helper enters two-digit input to select which position to change, your program should print 25 blank lines, so that the original board scrolls off the top of the screen and is no longer visible. To initialize the board variables use rand() to generate a random number. You should #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started