2d guess game..

Hello, so basically I have to create game where you have to find number in pair's in 2d, only problem is, I don't know where to start.

The game should look something like this -


    1 2 3 4 
 ------------
1 | * * * * 
2 | * * * * 
3 | * * * *
4 | * * * * 
Take first card
Enter row number ==> 2
Enter column number ==> 3

    1 2 3 4 
 ------------
1 | * * * * 
2 | * * 6 * 
3 | * * * *
4 | * * * * 
Take second card
Enter row number ==> 1
Enter column number ==> 2

    1 2 3 4 
 ------------
1 | * 6 * * 
2 | * * 6 * 
3 | * * * *
4 | * * * * 
You guessed first pair!
Onto the next one!
Last edited on
To keep checking if more pairs need to be found you would use a while loop. Something on lines of while (matches != 8) keep finding pairs.

Inide the while loop you should have some function calls, one to display the board, one to read the user inputs, one to check if there is a match etc.

The board itself should probably be made using 4x6 matrix with containing the asterics, but have another matrix containing numbers. The function call to read the inputs should replace the asteric with the number in the location you entered.

This might not be the best way to go about this but its how I did a similar program in my C++ class last semester. Make sure to use functions to help organize your program so you can test it piece by piece rather than doing it all at once and having a ton of errors to go through!
A modification of what the above poster said:

You should make a function called checkforwin(), which loops through the array checking if the number entered appears twice. If it does, the function returns true, else false. This return value should be caught in the loop in main, and the loop should terminate when the return value is true.
Topic archived. No new replies allowed.