Now that we can declare, initialize, and access arrays of many dimensions, we are ready to create functions to manipulate them:
- First, let's create a function to initialize a two-dimensional array and a function to initialize a three-dimensional array, as follows:
void initialize2DArray( int row , int col , int array[row][col] ) {
for( int j = 0 ; j < row ; j++ ) { // j : 0..(row-1)
for( int i = 0 ; i < col ; i++ ) { // i : 0..(col-1)
array[j][i] = (10*(j+1)) + (i+1);
}
}
}
void intialize3DArray( int x , int y , int z , int array[z][y][x] ){
for( int k = 0 ; k < z ; k++ ) { // k : 0..(z-1)
for( int j = 0 ; j < y ; j++ ) { // j : 0..(y-1)
for( int i = 0 ; i < x ; i++ ) { // i : 0..(x-1)
array[k][j][i] = (100*(k+1)) + (10*(j+1)) + (i+1);
}
}
}
}
In each function, nested loops are used to iterate over the entire...