0

3d matrix

class ThreeDMatrix { public static void main(String[] args) { int threeD[][][]=new int[3][4][5]; int i,j,k; for(i=0;i<3;i++) for(j=0;j<4;j++) for(k=0;k<5;k++) threeD[i][j][k]=i*j*k; { for(i=0;i<3;i++) for(j=0;j<4;j++){ for(k=0; k<5;k++) { System.out.print(threeD[i][j][k]); } System.out.println(); } System.out.println(); } } } check this code error

26th Jun 2017, 9:02 AM
maligireddy jalendarreddy
maligireddy jalendarreddy - avatar
1 Réponse
+ 4
/* Better code indentation should show more obviously your mistake: the third opening curly bracket is missplaced, and should stand just after the next 'for' statement and its condition argument enclosed in parenthesis (round brackets): */ class ThreeDMatrix { public static void main(String[] args) { int threeD[][][]=new int[3][4][5]; int i,j,k; for(i=0;i<3;i++) for(j=0;j<4;j++) for(k=0;k<5;k++) threeD[i][j][k]=i*j*k; for(i=0;i<3;i++) { for(j=0;j<4;j++) { for(k=0; k<5;k++) { System.out.print(threeD[i][j][k]); } System.out.println(); } System.out.println(); } } } // Anyway, the actual output will be more readable with some format: separator between values and/or same digit number for each value or conditional space to align matrix values display ^^
26th Jun 2017, 9:26 AM
visph
visph - avatar