返回列表 發帖
  1. public class Ch10
  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.         for(int x=0; x<3; x++)
  7.         {
  8.                 for(int y=0; y<4; y++)
  9.                 System.out.println("a["+x+"]["+y+"]="+a[x][y]);
  10.         }
  11.     }
  12. }
複製代碼
嗨嗨嗨嗨嗨嗨嗨嗨嗨

TOP

  1. public class Ch10
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         String x[]={"座號",  "姓名",  "國文",  "英文",  "數學",  "平均"};
  6.         String y[]={"叮叮",  "迪西",  "啦啦",  "小波",  "太陽"};
  7.         
  8.         int z[][]={{78,89,66},
  9.                           {77,67,34},
  10.                           {90,98,91},
  11.                           {57,59,81},
  12.                           {45,66,92}};
  13.         
  14.         int avg;
  15.         for(int i=0; i<6; i++)
  16.         
  17.                 System.out.print(x[i]+"\t");
  18.                 System.out.println( );
  19.                 System.out.println("==============================================");
  20.                 for(int i=0; i<5; i++)
  21.                 {
  22.                 System.out.print((i+1)+"\t"+y[i]+"\t");
  23.             for(int j=0; j<3; j++)
  24.                 System.out.print(z[i][j]+"\t");
  25.                  
  26.         avg=Math.round((float)(z[i][0]+z[i][1]+z[i][2])/3) ;
  27.         System.out.println(avg);
  28.         }
  29.     }
  30. }
複製代碼
嗨嗨嗨嗨嗨嗨嗨嗨嗨

TOP

返回列表