java 计算小鑫a+b 求解答

萌新求解答!万分感谢!!

img

注释也写的很清楚了,自己多看看吧

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        // 行数
        int lineCount = sc.nextInt();
        // 结果集
        List<List<String>> result = new ArrayList<>();
        // 循环行
        while (lineCount -- > 0) {
            // 每行的组数
            int group = sc.nextInt();
            // 每行的结果
            List<String> temp = new ArrayList<>();
            // 每行的有效数据
            int[] values = new int[group * 3];
            // 循环输入每行的有效数据
            for (int i = 0; i < values.length; i++) {
                values[i] = sc.nextInt();
                // 有3个数则开始计算
                if (i % 3 == 2) {
                    int a = values[i - 2];
                    int b = values[i - 1];
                    int c = values[i];
                    // 存入每行结果
                    temp.add(a + b == c ? "YES" : "NO");
                }
            }
            // 存入结果集
            result.add(temp);
        }
        // 输出结果
        for (List<String> res : result) {
            System.out.println(res);
        }
    }