Discuss / Java / 代码

代码

Topic source

昵称

#1 Created at ... [Delete] [Delete and Lock User]
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("测试失败");        }    }}

  • 1

Reply