返回列表 發帖
本帖最後由 張郁庭 於 2019-8-6 14:16 編輯
  1. public class Ch01
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         String title[]={"座號","姓名","國文","英文","數學","平均"};
  6.         String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
  7.         int score[][]={{84,95,78,0},
  8.                                {84,62,75,0},
  9.                                {75,65,84,0},
  10.                                {84,95,75,0},
  11.                                {64,65,74,89}};
  12.         for(int i=0; i<6; i++)
  13.                 System.out.print(title[i]+"\t");
  14.         System.out.println();
  15.         System.out.println("===========================================");
  16.         for(int i=0; i<5; i++)
  17.         {
  18.                 System.out.print((i+1)+"\t"+name[i]+"\t");
  19.                 for(int j=0; j<3; j++)
  20.                 {
  21.                         System.out.print(score[i][j]+"\t");
  22.                 }       
  23.                 float average=(float)((score[i][0]+score[i][1]+score[i][2])/3);
  24.                 System.out.println(Math.round(average));
  25.         }
  26.     }
  27. }
複製代碼

TOP

返回列表