public class Main { public static void main(String[] args) { // 用二维数组表示的学生成绩: int[][] scores = { { 82, 90, 91 }, { 68, 72, 64 }, { 95, 91, 89 }, { 67, 52, 60 }, { 79, 81, 85 }, }; // TODO: double average = 0; int sum=0; for (int i = 0; i < scores.length; i++) { int[] A=scores[i]; for (int j = 0; j <A.length ; j++) { sum+=A[j]; } average+=(double)sum/A.length; sum=0; } average=average/scores.length; System.out.println(average); if (Math.abs(average - 77.733333) < 0.000001) { System.out.println("测试成功"); } else { System.out.println("测试失败"); } }}
Sign in to make a reply
昵称