fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. int num[][][]={{{53,45,234,1},{6234,34,34,7},{34,23,123,34}},{{56,34,3,2},
  14. {9,3,6,4},{8,5,5,3}}};
  15. int i,j,k,sum=0;
  16. System.out.print("三维数组:");
  17. for( i=0;i<num.length;i++)
  18. {
  19. for(j=0;j<num[i].length;j++)
  20. {
  21. for(k=0;k<num[i][j].length;k++)
  22. {
  23. System.out.print(num[i][j][k]+" ");
  24. sum+=num[i][j][k];
  25. }
  26. }
  27. }
  28. System.out.println();
  29. System.out.println("三维数组和:"+sum);
  30.  
  31. }
  32. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
三维数组:53 45 234 1 6234 34 34 7 34 23 123 34 56 34 3 2 9 3 6 4 8 5 5 3 
三维数组和:6994