返回列表 發帖
  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.         for(int i=0; i<=5; i++)
  8.             System.out.print(title[i]+"\t");
  9.         System.out.print("\n===============================================\n");
  10.         for(int i=0; i<=4; i++)
  11.         {
  12.                 float avg;
  13.                 avg=(score[i][0]+score[i][1]+score[i][2])/3;
  14.                 avg=Math.round(avg);
  15.                 System.out.print(i+1+"\t"+name[i]+"\t");
  16.             for(int j=0; j<=2; j++)
  17.                     System.out.print(score[i][j]+"\t");
  18.             System.out.println((int)avg);
  19.         }
  20.     }
  21. }
複製代碼

TOP

返回列表