返回列表 發帖
  1. public class Ch01 {
  2.         public static void main(String[] args)
  3.         {
  4.                 String title[]={"座號","姓名","國文","英文","數學","平均"};
  5.                 String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
  6.                 int score[][]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
  7.                 int avg;
  8.                 for(int i=0; i<6; i++)
  9.                         System.out.print(title[i]+"\t");
  10.                 System.out.println();
  11.                 System.out.println("============================================================");
  12.                 for(int i=0;i<5; i++)
  13.                 {
  14.                         System.out.print((i+1)+"\t"+name[i]+"\t");
  15.                         for(int j=0; j<3; j++)
  16.                         {
  17.                                 System.out.print(score[i][j]+"\t");
  18.                         }
  19.                         avg=Math.round((float)(score[i][0])+score[i][1]+score[i][2])/3);
  20.                         System.out.println(avg);
  21.                        
  22.                 }
  23.         }
  24.         
複製代碼

TOP

  1. public class Ch01 {
  2.         public static void main(String[] args)
  3.         {
  4.                 int a[]={1,2,3,4}
  5.                 int b[][]={{1,2,3,4},{1,2,3,4},{1,2,3,4}};
  6.                 int c[][][]={{{1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4}}}
  7.                 System.out.println(a.length);     //4
  8.                 System.out.println(b.length);     //3
  9.                 System.out.println(c.length);     //2
  10.         }
  11. }        
複製代碼

TOP

返回列表