Arrays

Hi Im trying to create a game where ive got to create a 3 x 3 array and i've got to get the user to guess the numbers in the array (1-9) I think Ive got the rand array and integer array right (not sure though) but im stuck on the memory array where i want the program to remember where the user has already gone and if the user doesnt get it in 9 goes ,the program stops. My code isn't compiling at the moment so if anyone has some spare time to have a look at my code I'd very much appreshiate it.

Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include<iostream>
#include<conio.h>
#include<string>
#include<cstdlib>
#include<ctime>

using namespace std;

int pause()						
{
	int in;
	scanf("%c",&ch);			
	getint();					
	return 0;
}

int main ()
{
   
   
	cout<< "Welcome" <<endl;


//This is the Character Array	
 int coveredarray [3][3] =    {{'?','?','?'},	                          
                                {'?','?','?'},
                                {'?','?','?'}};
                                
                                
    for(int row = 0; row < 3; row++)
    {
        for(int column = 0; column < 3; column++)
        {
            cout << coveredarray[row][column] << " ";

		}
            cout << endl;
        }
//This is the Guess Array

int guessarray[3][3]; 
	
	*srand(time(0)); 
    guessarray = (rand() % 3) ;
	if (guessarray>1 && guessarray <9) +1;
	for(int row = 0; row <3; row++)
	{ for(int column = 0; column <3; column++)
		{ cout << guessarray[row][column];
		}
	}
		
        }

     int playarray[3][3]; 

	 int row, column;
	 int turn= 1, mine_ctr=0; 
	 int play_row, play_column;

     while (turn < 9) { //I'm going to use While Loops
	 cout<< "Turn"<< playarray <<endl;
	 cout<<endl;

	 if((play_row > 1) && (play_column < 3))
	 {
		 cout<< "Please enter a number of row and column" <<endl;
		 system ("pause") ;
		 continue;
		 
	 if((guessarray[play_row-1][play_column-1] <= 9) 
		 cout << "Number found" << endl;
		 displayarray[play_row-1][play_colum-1] ='' ;
		 mine_ctr++;
		 for (int row=0; row<3; row++)
		 {
			 cout<<coveredarray [row][column]<<" ";
		 }
		 
		 cout<<endl;
	 }
	 }
	 else
	 {
		 cout << "Wrong Number" << endl; 
		 displayarray[play_row-1][play_column-1] = '?';

		  cout << endl;
			 }

			 if(guessarray[play_row-1][play_column-1] == 1;
			 {
				 cout << "Please choose another position" 
				 system("pause");
				 continue;

				 guessarray[play_row-1][play_row-1]=1;

			 if(guess_ctr =9)
			 {
				 cout << "numbers found" << endl;
				 break;
			 }

			 turn++;

		 }
		 if (turn==10)
		 {
			 cout << " lost" << endl;

_getch()
}
closed account (Dy7SLyTq)
line 44: your setting an array as an lvalue instead of its elements
same with line 45, and for some reason you have a random +1 at the end which wont compile. line 61 doesnt make any sense. you are a)trying to print an array object and not the elements of it b) using to tell the turn when you have a counter to tell you the turn
I dont know if you can help me but with line 61 im trying to get the user to select a number for a column and row so that the user can guess a number 1-9 what number is contained below the "?", do you know how can go about it?
Last edited on
Topic archived. No new replies allowed.