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 }, }; double add=0; for(int i=0;i<=scores.length-1;i++){ for(int j=0;j<=2;j++){ add=add+scores[i][j];// TODO: } } double average=add/(3*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
光哐哐哐哐