-
array [x] [y] = z //??
i'm reading from deitel & deitel 3rd ed, pg 337
in the above array, is z copied into both subscripts?
here's more of the code
Code:
void shuffle (int wDeck [] [13])
{
int row, column;
for (int card=1; card<=52; card++)
{
do
{ row=rand() %4;
column=rand() %13;
}
while (wDeck [row] [column] != 0 );
wDeck [row][column] =card;//?
}}
-
No. The array is two dimesional. The x and y each contain the index number for its dimension, the two combined point to one cell. The assignment: array[x] [y]=z; puts z into that cell.
-
think of the 2 d array as a checker board. Each squareof the checker board is refered to be a row and a column, but each square may hold any of a variety of things, in checkers it may hold nothing, a red or black checker or a red or black king. The same with the array. Each [x][y] combination represents a different "cell" or space or whatever you want to call it. Each "cell" or space can hold a variety of things, called z in the code you posted, depending on what the type of the array is.