返回列表 發帖
本帖最後由 潘憶承 於 2019-8-6 14:26 編輯
  1. public class Ch02
  2. {
  3.         public static void main(String args[])
  4.         {
  5.                 String title[]={"座號","姓名","國文","英文","數學","平均"};
  6.                 String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
  7.                 int score[][]={{78,89,66},
  8.                                 {77,67,34},
  9.                                 {90,98,91},
  10.                                 {57,59,81},
  11.                                 {45,66,92}};
  12.                 int avg;
  13.                 for(int i=0;i<6;i++)
  14.                         System.out.print(title[i]+"\t");
  15.                 System.out.println();
  16.                 System.out.println("===========================================");
  17.                 for(int i=0;i<5;i++)
  18.                 {
  19.                         System.out.print((i+1)+"\t"+name[i]+"\t");
  20.                         for(int j=0;j<3;j++)
  21.                         {
  22.                                 System.out.print(score[i][j]+"\t");
  23.                         }
  24.                         avg=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
  25.                         System.out.println(avg);
  26.                 }
  27.         }
  28. }
複製代碼

TOP

返回列表