2 dimensional array question
I racked my brain for a day and can't figure it out. It is extremely frustrating but I just can't give up.
Suppose a bingo is build with an nXn array like this.
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
41 42 43 44 45
51 52 53 54 55
n can be any integer and its value is input by users.
Here are my questions:
1. I want to define 2 arrays so that
int array1[n][n];
int array2[n][n];
You know n is unknown. It is just illegal to do that. Any trick can do it ?
2.
The entries of the table is input by users.
A row is entered at a line.
eg.
11 12 13 14 15
21 22 23 24 25
How to end a line after "cin>>"?
3.
This is really one big headache for me.
After inputting all entries in the table, users choose number randomly. If a chosen number match with an entry in a table, the entry is clear. When a row , column or diagonal is clear, the game is ended.
Here is my idea:
array1 is used to store the value of the entries in the table.
array2 is used to store the value that determine whether the entries in the table is clear or not .
If an entry (array1[row][col]) in the table is clear, then array2[row][col]=1.
Else, array2[row][col]=0.
I just can't figure out how to write the condition that a row , column or diagonal is clear. Any idea? Does my idea work?
Plz save my life.