返回列表 發帖
  1. public class Ch02
  2. {
  3.     public static void main(String args[])
  4.     {
  5.       String title[]={"座號","姓名","國文","英文","數學","平均"};
  6.       String name[]={"蔡哥","昊哥","白鴿","帥哥","蝦咪挖哥"};
  7.       int score[][]={{99,99,99},
  8.                              {87,87,87},
  9.                              {69,69,69},
  10.                              {78,78,78},
  11.                      {1000,1000,1000}};
  12.       int avg;
  13.       
  14.       for(int i=0; i<6; i++)
  15.               System.out.print(title[i]+"\t");
  16.       System.out.println();
  17.       System.out.println("=============================================");
  18.       for(int i=0; i<5; i++)
  19.       {
  20.               System.out.print((i+1)+"\t"+name[i]+"\t");
  21.               for(int j=0; j<3; j++)
  22.               {
  23.                     System.out.print(score[i][j]+"\t");  
  24.               }
  25.               avg=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
  26.               System.out.println(avg);
  27.       }
  28.     }
  29. }
複製代碼

TOP

返回列表