Difference between revisions of "Multi-dimensional Arrays"
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{1010PrAD|ProblemName=Multi-dimensional Arrays | {{1010PrAD|ProblemName=Multi-dimensional Arrays | ||
− | |Problem= Create three arrays, two that are 2-dimensional (2-d) and a third one that is 3 dimensional (3-d). The first 2-d array will be 5x5 and you will need to store an integer value that will correspond to the row and column in the array, ie. 24, means row 2 column 4. The second 2-d array will store the multiplication table from 1 to 9. The 3-d array will store the sum co-ordinates on the cube created by visualizing the array where the centre of the cube is 0,0,0 so a 5x5x5 array would have the co-ordinates (0,0,0) at location 3 (location 2 in the java array since indexing starts at 0) ie. co-ordinate (1,-2,0) would be array[3][0][2] and would store the value 1+(-2)+0= -1. All co-ordinates in the 3-d array will be in the form (x,y,z) and correspond directly to the 3-d array in the same form, so the 3-d array would be indexed array[x][y][z]. Create a 7x7x5 3-d array. All arrays will be integer arrays. | + | |Problem= Create three arrays, two that are 2-dimensional (2-d) and a third one that is 3 dimensional (3-d). The first 2-d array will be 5x5 and you will need to store an integer value that will correspond to the row and column in the array, ie. 24, means row 2 column 4. The second 2-d array will store the multiplication table from 1 to 9. The 3-d array will store the sum co-ordinates on the cube created by visualizing the array where the centre of the cube is 0,0,0 so a 5x5x5 array would have the co-ordinates (0,0,0) at location 3 (location 2 in the java array since indexing starts at 0) ie. co-ordinate (1,-2,0) would be array[3][0][2] and would store the value 1+(-2)+0= -1. All co-ordinates in the 3-d array will be in the form (x,y,z) and correspond directly to the 3-d array in the same form, so the 3-d array would be indexed array[x][y][z]. Create a 7x7x5 3-d array. All arrays will be integer arrays and all arrays are to be created with corresponding methods that take parameters and return a newly created array. |
|SideSectionTitle = Introducing Arrays | |SideSectionTitle = Introducing Arrays | ||
|SideSection= | |SideSection= | ||
Line 8: | Line 8: | ||
|SolutionCode= | |SolutionCode= | ||
− | public class | + | public class MultArrays{ |
− | public static void main(){ | + | public static void main(String[] args){ |
− | + | ||
} | } | ||
} | } |
Latest revision as of 11:46, 15 April 2010
Back to the Program-A-Day homepage
ProblemCreate three arrays, two that are 2-dimensional (2-d) and a third one that is 3 dimensional (3-d). The first 2-d array will be 5x5 and you will need to store an integer value that will correspond to the row and column in the array, ie. 24, means row 2 column 4. The second 2-d array will store the multiplication table from 1 to 9. The 3-d array will store the sum co-ordinates on the cube created by visualizing the array where the centre of the cube is 0,0,0 so a 5x5x5 array would have the co-ordinates (0,0,0) at location 3 (location 2 in the java array since indexing starts at 0) ie. co-ordinate (1,-2,0) would be array[3][0][2] and would store the value 1+(-2)+0= -1. All co-ordinates in the 3-d array will be in the form (x,y,z) and correspond directly to the 3-d array in the same form, so the 3-d array would be indexed array[x][y][z]. Create a 7x7x5 3-d array. All arrays will be integer arrays and all arrays are to be created with corresponding methods that take parameters and return a newly created array. |
Introducing Arrays | |
---|---|---|
Solution | ||
Code |