返回列表 發帖
  1. public class Ch10{
  2.         public static void main(String[]args)
  3.         {
  4.                 String title[]={"號","名","國","英","數","平均"};
  5.                 String name[]={"a","s","d","f","g","h"};
  6.                 int score[][]={{90,88,89},
  7.                                 {70,67,54},
  8.                                 {89,88,90},
  9.                                 {17,33,56},
  10.                                 {77,79,46}};
  11.                 for(int i=0; i<6;i++)
  12.                         System.out.print(title[i]+"\t");
  13.                 System.out.println("\n=============================================");
  14.                 for(int i=0; i<5;i++)
  15.                 {
  16.                         System.out.print((i+1)+"\t"+name[i]+"\t");
  17.                         for(int j=0; j<3; j++)
  18.                                 System.out.print(score[i][j]+"\t");
  19.                         float avg=(float)(score[i][0]+score[i][1]+score[i][2])/3;
  20.                         System.out.println(avg);
  21.                 }       
  22.         }
  23. }
複製代碼

TOP

返回列表