C++ Grid for TheNameGame

Hello, I am literally just starting a class for C++ and below is one of the assignments the teacher gave. i am currently confused about how to actually get the grid and create a random number generator.

For this assignment, you will design a game called . In this game there is one player who
is playing against the computer. The game presents the player with a grid with numbers shown in a 3 x 3 chart.

At the start of the game, the game will print a message to explain to the player,
welcome them, and ask them for three initials of the player’s name. The game will then use a random
number generator to generate six numbers between 1 and 9. The player will NOT be shown the six
numbers. The game will use the six numbers to place the initials twice in the chart at the given positions.


Any type of help would be appreciated, thanks in advance.
Hello loskers,

This is better. Sorry it took so long to see your post. Been dealing with a headache most of the day.

I look at the instructions and feel that this is not the complete instructions.

Working with what is there I see a 2D array to hold the numbers.

A function to display the array to the screen.

I see generating six random numbers. The instructions do not say, but I feel as the six random numbers should be unique, i.e., no duplicate numbers.

You could use the "random" header file and what is there to generate the random numbers. Or use "srand()" and "rand()". In the function using "rand" you can code to produce six unique numbers.

Start in small steps. Create the main file with the header file "iostream" Then the main function. Define the 2D array inside main followed by any variables that you think of then code for the initial output to the screen and the initial input that you will need.

After this I would create a function to generate the random numbers. If you decide to use "srand()" and "rand()" you need to put "srand" near the beginning of the main function because "srand" should be called only once when the program starts.

That should get you started. Once you have some code and have problems ask your question(s) and post the code to get suggestions and/or corrections or even some ideas.

Hope that helps,

Andy
Topic archived. No new replies allowed.