# MAZE Problem

Show 80 post(s) from this thread on one page
Page 4 of 5 First 12345 Last
• 04-01-2008
peacealida
I am confused...XX.....

But how can i add element into this???
like above??

..... sorry
• 04-01-2008
peacealida
i think i figure out now hahah
thx thx
• 04-01-2008
tabstop
Quote:

Originally Posted by peacealida
I am confused...XX.....

But how can i add element into this???
like above??

..... sorry

I have an example posted already. You have one array -- it has three dimensions. If you're going to initialize it, you have to do it now, when you declare it, and you need to initialize it all (or at least everything you plan to do). So do so. We're going to do the random one later, but we need all 0's so:
Code:

```{ {{0}},```
Then you need the first array; copy and paste the whole thing in from
Code:

```{{ lots of numbers up to}} }```
. And there you are.
• 04-01-2008
peacealida
Code:

```int matrix[MATRIX_SIZE][MATRIX_SIZE]; int matrix_data[2][MATRIX_SIZE][MATRIX_SIZE]; ={ {{0}}, { {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},     {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},     {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},     {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},     {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0},     {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},     {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},     {0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0},     {0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0},     {0,0,0,0,0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,0,0,1,0,0,0,0,0,0,0},     {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},     {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},     {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0},     {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},     {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},     {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}   };} return matrix_data[0]; int trace_matrix[MATRIX_SIZE][MATRIX_SIZE];```
these should make sense?

What i need to write in the int main() ?

i think i need to allow the user input and read the data from the array and output.

I am trying to produce the code, but it comes more than 15 errors.

Wt else do u need to modify????

-----------THX---THX-------------
• 04-01-2008
peacealida
Code:

``` int main() {     cout <<"Ender Maze wanted, 0,1,2,3:\n";     cout <<"    0- Random Maze\n";     cout <<"    1- Set Maze (1)\n";     cout <<"    2- Exit\n";     cin >> x;         return 0;```
I have put these into the int main() What else is missing? Or i need to define other function??
plz help

cheers
• 04-01-2008
tabstop
Quote:

Originally Posted by peacealida
Code:

``` int main() {     cout <<"Ender Maze wanted, 0,1,2,3:\n";     cout <<"    0- Random Maze\n";     cout <<"    1- Set Maze (1)\n";     cout <<"    2- Exit\n";     cin >> x;         return 0;```
I have put these into the int main() What else is missing? Or i need to define other function??
plz help

cheers

Who knows what's missing? This doesn't do anything apart from: printing a menu, and getting a choice back. Everything else you want done, you have to do.
• 04-01-2008
peacealida
OIC
This is what i though coz they dun read the input and get the output.
so i need to create a function for the data to process!?

So i need specific 0 is to choose the map [0]
and 1 i choose map[1]??

for(int maze=0; maze<3 ; maze++)
cout<<matrix_size[maze]<<"------"<<matrix_data[n]<<endl;
these should put inside the int main() or void()??

I am really sorry for all these......
• 04-01-2008
tabstop
You can do it inside main directly, or put it another function, as you wish; but if you put it in another function you do have to call that function from main, or else it won't happen. Notice that there is no function called void().
• 04-01-2008
peacealida
Sorry
So i think i will put them inside the main...

using printf and scanf

are they more useful for me?? (I know it sounds weired)

I will use that method to see does it get me anywhere.Thanks

I am sorry for all these question, but i really trying to get them work, I have not stopping on these since you repled me this morning ahahaha.

---------Thanks God------------
• 04-01-2008
peacealida
I have done the following changes in the int main()

Code:

```int main() using namespace std; {         int maze;         cout <<"Enter Maze wanted, 0,1,2,3:\n";     cout <<"    0- Random Maze\n";     cout <<"    1- Set Maze (1)\n";     cout <<"    2- Exit\n";         cin >> maze;     {     for (maze =0; maze < matrix_data[n]; maze++)         cout<<matrix_data[n] <<endl;     }```
still 3 errors, any 1 can point out wt's going on????
Thanks Thanks
• 04-01-2008
tabstop
The three errors tell you exactly what's going on:
unclosed brace on line "{" (right after cin >> maze)
variable n not defined
unable to compare int (maze) with int[][] (matrix_data[n]) (although your error might say something about conversions from int[][] to int)

Not a compile error, probably, but cout << matrix_data[n] will probably print out a hex memory address, since matrix_data[n] decays into a pointer.
• 04-01-2008
peacealida
Still getting syntax error

Code:

```int main() using namespace std; {     int maze[][], n;         cout <<"    Enter Maze wanted, 0,1,2:\n";     cout <<"    0- Random Maze\n";     cout <<"    1- Set Maze (1)\n";     cout <<"    2- Exit\n";         cin >> maze[][];     matrix_data[n] =maze[][];     {     for (maze[][] =0; maze[][] < matrix_data[n]; maze[][]++)     cout<<matrix_data[n] <<endl;     printf("%d\n", matrix_data[n]);     return 0; } }```

i am also having error on this line....
Code:

```int matrix_data[2][MATRIX_SIZE][MATRIX_SIZE]; ={ {{0}}, { {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},     {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},     {0,```

also wt this mean?

"unable to compare int (maze) with int[][] (matrix_data[n]) "
• 04-01-2008
tabstop
Quote:

Originally Posted by peacealida
Still getting syntax error

Code:

```int main() using namespace std; {     int maze[][], n;         cout <<"    Enter Maze wanted, 0,1,2:\n";     cout <<"    0- Random Maze\n";     cout <<"    1- Set Maze (1)\n";     cout <<"    2- Exit\n";         cin >> maze[][];     matrix_data[n] =maze[][];     {     for (maze[][] =0; maze[][] < matrix_data[n]; maze[][]++)     cout<<matrix_data[n] <<endl;     printf("%d\n", matrix_data[n]);     return 0; } }```

i am also having error on this line....
Code:

```int matrix_data[2][MATRIX_SIZE][MATRIX_SIZE]; ={ {{0}}, { {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},     {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},     {0,```

also wt this mean?

"unable to compare int (maze) with int[][] (matrix_data[n]) "

Does the initializer continue after the 0, ? You can't just stop.

And the last means what it says: you can't compare (using < for less than) an integer to a matrix. What would that mean?
• 04-01-2008
peacealida
Code:

```              .               .               .               . ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},     {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},     {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}   };} return matrix_data[0]; int trace_matrix[MATRIX_SIZE][MATRIX_SIZE]; void output_program(struct prog *progp) {   char *codep = progp->code;   int token;         while (token = *codep++)     fputs(token_table[token].name, stdout);   putchar('\n'); } void print_matrix(void) {  int i, j; char symbs[] = " OX";   for (i=0; i < MATRIX_SIZE; i++)   {  for (j=0; j < MATRIX_SIZE; j++)           putchar(symbs[trace_matrix[i][j]]);       putchar('\n');   } }```
This is the end of it....

Code:

`for (maze[][] =0; maze[][] << matrix_data[n]; maze[][]++)`
So aboe must be wring...

If i can't use integer to a matrix,,,, so how can i retrieve the data?

Thanks Thanks
• 04-01-2008
tabstop
Notice in your initializer that you've embedded the semicolon in the thing, rather than being at the end like it should.

Quote:

Code:

`for (maze[][] =0; maze[][] << matrix_data[n]; maze[][]++)`

This is so amazingly wrong that it makes me give up hope.

matrix_data is a 3-dimensional array.
matrix_data[0] is a 2-dimensional array (namely, a map).
matrix_data[0][1] is a 1-dimensional array (specifically, the second row of the map).
matrix_data[0][1][2] is an integer (the third number in the second row of the map).

You can only deal with specific elements of the array.
Show 80 post(s) from this thread on one page
Page 4 of 5 First 12345 Last