返回列表 發帖

陣列 (三) - 二維陣列

一個 3x4 的二維陣列 可存放 12 筆資料

  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}};
  6.         for(int i=0; i<3; i++)
  7.         {
  8.             for(int j=0; j<4; j++)
  9.                 System.out.println("n["+i+"]["+j+"]="+n[i][j]);
  10.         }
  11.     }
  12. }
複製代碼

  1. public class Ch66
  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.     for(int i=0;i<3;i++)
  7.     {
  8.       for(int j=0;j<4;j++){
  9.         System.out.println("n["+i+"]["+j+"]="+n[i][j]);

  10. }
  11.     }
  12.   }
  13. }
複製代碼

TOP

  1. public class QTQ
  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.         for(int i=0; i<3; i++)
  7.         {
  8.             for(int j=0; j<4; j++)
  9.                 System.out.println("n["+i+"]["+j+"]="+n[i][j]);
  10.         }
  11.     }
  12. }
複製代碼

TOP

  1. public class A01
  2. {
  3. public static void main(String args[])
  4. {
  5.   int n[][]={{1,2,3,4},
  6.              {5,6,7,8},
  7.              {9,10,11,12}};
  8.              for(int i=0;i<3;i++)
  9.              {
  10.              for(int a=0;a<=3;a++)
  11.              System.out.println("n["+i+"]["+a+"]="+n[i][a]);

  12.                }


  13.   }



  14. }
複製代碼

TOP

  1. public class Ch24
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][]={{1,2,3,4},
  6.                    {5,6,7,8},
  7.                    {9,10,11,12}};
  8.         for(int i=0; i<3; i++)
  9.         {
  10.             for(int j=0; j<4; j++)
  11.             System.out.println("n["+i+"]["+j+"]="+n[i][j]);
  12.         }
  13.     }
  14. }
複製代碼

TOP

  1. public class qq
  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.         for(int i=0; i<3; i++)
  7.         {
  8.             for(int j=0; j<4; j++)
  9.                 System.out.println("n["+i+"]["+j+"]="+n[i][j]);
  10.         }
  11.     }
  12. }
複製代碼

TOP

  1. public class a3
  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.         for(int i=0; i<3; i++)
  7.         {
  8.             for(int j=0; j<4; j++)
  9.                 System.out.println("n["+i+"]["+j+"]="+n[i][j]);
  10.         }
  11.     }
  12. }
複製代碼

TOP

  1. public class Ch686
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int n[][]={{1,2,3,4},
  6.                    {5,6,7,8},
  7.                    {9,10,11,12}};
  8.         for(int i=0; i<3; i++)
  9.         {
  10.             for(int j=0; j<4; j++)
  11.                 System.out.println("n["+i+"]["+j+"]="+n[i][j]);
  12.         }
  13.     }
  14. }
複製代碼

TOP

  1. public class H2
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         int x[][]={{1,2,3,4},{5,6,7,8},{9,10,11,12}};
  6.         for(int i=0; i<3; i++)
  7.         {
  8.             for(int j=0; j<4; j++)
  9.                 System.out.println("n["+i+"]["+j+"]="+x[i][j]);
  10.         }
  11.     }
  12. }
複製代碼

TOP

返回列表