One-dimensional array is used as two-dimensional, and dimension array is used as two-dimensional
# Include <stdio. h>
Int main (void)
{
Int I, j;
Int a [] = {, 35 };
Typedef int (* Type) [5];
Type B = (Type);
For (I = 0; I <5; ++ I)
{
For (j = 0; j <5; ++ j)
Printf ("% d", B [I] [j]);
Printf ("\ n ");
}
Return 0;
}
What is access to a two-dimensional array using a one-dimensional array? What should I do if y (4) and y (2, 1) are the same variables?
This is what LZ can look.
Data storage is stored one by one in order. When a two-dimensional array is stored, the first uniqueness is stored first, and then the second uniqueness is stored: the last and first of the second dimensions of the first dimension are adjacent!
That is to say, when you exceed the number of dimensions in the first dimension, the second dimension is automatically searched!
Therefore, if y (4) exceeds y (3), the first number of y (2, 1) in the second dimension is searched.
LZ can draw pictures to think about it.
How do two-dimensional arrays represent one-dimensional arrays?
Sz [1] [32] = {
{0xff, 0xfe, 0xff, 0xfd, 0xff, 0xfb, 0xff, 0xf7,
0xff, 0xef, 0xff, 0xdf, 0xff, 0xbf, 0xff, 0x7f,
0xfe, 0xff, 0xfd, 0xff, 0xfb, 0xff, 0xf7, 0xff,
0xef, 0xff, 0xdf, 0xff, 0xbf, 0xff, 0x7f, 0xff}
};
This is an array definition. It indicates that the array has one row and 32 columns. The first column of the array starts from sz [0] [0] to sz [0] [31].
Sz [0] [j] refers to the number of j in the first line, for example, sz [0] [3] = 0xff,
Sz [0] indicates the first line of sz [0] = {0xff, 0xfe, 0xff, 0xfd, 0xff, 0xfb, 0xff, 0xf7,
0xff, 0xef, 0xff, 0xdf, 0xff, 0xbf, 0xff, 0x7f,
0xfe, 0xff, 0xfd, 0xff, 0xfb, 0xff, 0xf7, 0xff,
0xef, 0xff, 0xdf, 0xff, 0xbf, 0xff, 0x7f, 0xff}