返回列表 發帖
  1. public class Ch01
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         String title[]={"座號","姓名","國文","英文","數學","平均"};
  6.         String name[]={"小叮噹","大雄","怡靜","濟安","阿福"};
  7.         
  8.         int score[][]={{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(title[i]+"\t");
  18.         System.out.println();
  19.         System.out.println("=================================================");
  20.         for(int i1=0; i1<5; i1++)
  21.         {
  22.                 System.out.print((i1+1)+"\t"+name[i1]+"\t");
  23.                 for(int j=0; j<3; j++)
  24.                 {
  25.                         System.out.print(score[i1][j]+"\t");
  26.                 }
  27.                 avg=Math.round((float)(score[i1][0]+score[i1][1]+score[i1][2])/3);
  28.                 System.out.println(avg);
  29.           }                     
  30.     }
  31. }
複製代碼

TOP

返回列表