A multidimensional array in C + + is an array of exponential groups:
int ia[3][4][5];//a is an array of size 3, each of which is an array of size 4, and the elements of those arrays are all arrays that contain 5 integers.
References to two-dimensional arrays:
1. Use the range for statement
for (int (&p) [4]: a) {//p is a reference, referencing an array containing 4 integers
for (int q:p)
cout << Q;
cout << Endl;
}
2. Use subscript
for (int i = 0; I! = rowcnt; i++) {
for (int j = 0; J! = colcnt; j + +)
cout << A[i][j];
cout << Endl;
}
3. Use the pointer
for (int (*p) [4] = A; P! = a + 3; p++) {//p is a pointer to an array with 4 integers, note the difference from int *p[4] (an array with 4 integer pointers)
for (int *q = *p; Q! = *p + 4; q++)//*p is an array with 4 integers, and the array name is automatically converted to a pointer
cout << *q;
cout << Endl;
}
C + + multidimensional arrays