返回列表 發帖

陣列 (四) - 三維陣列

一個 2x3x4 的三維陣列 可存放 24 筆資料

  1. //2x3x4
  2. public class Ch37
  3. {
  4.     public static void main(String args[])
  5.     {
  6.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},
  7.                      {{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  8.         for(int i=0; i<2; i++)
  9.         {
  10.             for(int j=0; j<3; j++)
  11.             {
  12.                 for(int k=0; k<4; k++)
  13.                     System.out.println("n["+i+"]["+j+"]["+k+"]="+n[i][j][k]);
  14.             }
  15.         }
  16.     }
  17. }
複製代碼

  1. public class Ch34
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},
  6.                      {{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  7.         for(int i=0; i<2; i++)
  8.         {
  9.             for(int j=0; j<3; j++)
  10.             {
  11.                 for(int k=0; k<4; k++)
  12.                     System.out.println("n["+i+"]["+j+"]["+k+"]="+n[i][j][k]);
  13.             }
  14.         }
  15.     }
  16. }
複製代碼

TOP

本帖最後由 陳宥穎 於 2020-8-28 20:12 編輯
  1. public class Ch12
  2. {
  3.    public static void main(String args[])
  4.    {
  5.      int a[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},{{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  6.      for(int i=0; i<2; i++)
  7.      {
  8.       for(int k=0; k<3; k++)
  9.       {
  10.         for(int b=0; b<4; b++)
  11.          System.out.println("a["+i+"]["+k+"]["+b+"]="+a[i][k][b]);
  12.       }
  13.      }
  14.    }
  15. }
複製代碼

TOP

  1. public class Ch37
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},
  6.                      {{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  7.         for(int i=0; i<2; i++)
  8.         {
  9.             for(int j=0; j<3; j++)
  10.             {
  11.                 for(int k=0; k<4; k++)
  12.                     System.out.println("n["+i+"]["+j+"]["+k+"]="+n[i][j][k]);
  13.             }
  14.         }
  15.     }
  16. }
複製代碼

TOP

  1. public class Ch36
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},{{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  6.         for(int i=0;i<2;i++)

  7.             for(int j=0;j<3;j++)
  8.                 for (int k=0;k<4;k++)
  9.                     System.out.println("n["+i+"]["+j+"]["+k+"]="+n[i][j][k]);


  10.     }

  11. }
複製代碼

TOP

  1. public class Ch01
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},{{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  6.         for(int i=0;i<2;i++)
  7.             for(int j=0;j<3;j++)
  8.                 for(int k=0;k<4;k++)
  9.                     System.out.println("n["+i+"]["+j+"]["+k+"]="+n[i][j][k]);
  10.     }
  11. }
複製代碼

TOP

  1. public class Ch34
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},
  6.                      {{13,14,15,16},{17,18,19,20},{21,22,23,24}}};

  7.         for(int i=0; i<2; i++)
  8.         {
  9.             for(int j=0; j<3; j++)
  10.             {
  11.                 for(int k=0; k<4; k++)
  12.                     System.out.println("n["+i+"]["+j+"]["+k+"]="+n[i][j][k]);
  13.             }
  14.         }
  15.     }
  16. }
複製代碼

TOP

  1. public class Ch25
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},
  6.                      {{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  7.         for(int a=0; a<2; a++)
  8.             for(int b=0; b<3; b++)
  9.                 for(int c=0; c<4; c++)
  10.                     System.out.println("n["+a+"]["+b+"]["+c+"]="+n[a][b][c]);
  11.     }
  12. }
複製代碼
李宇澤Oscar

TOP

  1. public class Ch37
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},
  6.                      {{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  7.         for(int i=0; i<2; i++)
  8.         {
  9.             for(int j=0; j<3; j++)
  10.             {
  11.                 for(int k=0; k<4; k++)
  12.                     System.out.println("n["+i+"]["+j+"]["+k+"]="+n[i][j][k]);
  13.             }
  14.         }
  15.     }
  16. }
複製代碼
Huang chenhao

TOP

  1. public class Ch30
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int a[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},
  6.                    {{13,14,15,16},{17,18,19,20},{21,22,23,24}}};

  7.         for(int i=0; i<2; i++)
  8.             for(int j=0; j<3; j++)
  9.                 for(int k=0; k<4; k++)
  10.                     System.out.println("a["+i+"]["+j+"]["+k+"="+a[i][j][k]);
  11.     }
  12. }
複製代碼
hahahahahahahaha

TOP

  1. public class Ch32
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},{{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  6.         for(int i=0; i<2; i++)
  7.             for(int j=0; j<3; j++)
  8.                 for(int k=0; k<4; k++)
  9.                     System.out.println("n["+i+"]["+j+"]["+k+"]="+n[i][j][k]);

  10.     }
  11. }
複製代碼

TOP

  1. public class Ch30
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][][]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},
  6.                      {{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
  7.         for(int i=0; i<2; i++)
  8.             for(int j=0; j<3; j++)
  9.                 for(int k=0; k<4; k++)
  10.                     System.out.println("n["+i+"]["+j+"]["+k+"]="+n[i][j][k]);
  11.     }
  12. }
複製代碼

TOP

返回列表