- public class Ch31 {
- public static void main(String[] args) {
- String title[]={"座號","姓名","國文","英文","數學","平均"};
- String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
- int score[][]={{90,85,85,0},
- {70,75,80,0},
- {80,95,80,0},
- {70,95,75,0},
- {80,85,95,0}};
- for(int i=0;i<6;i++)
- System.out.print(title[i]+"\t");
- System.out.println("\n===========================================");
- for(int i=0;i<5;i++)
- {
- System.out.print((i+1)+"\t"+name[i]+"\t");
- score[i][3]=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
- for(int j=0;j<4;j++){
- System.out.print(score[i][j]+"\t");
- }
- System.out.println();
- }
- }
- }
複製代碼 |