当前位置: 代码迷 >> 综合 >> 1061 判断题 (15分)Java
  详细解决方案

1061 判断题 (15分)Java

热度:49   发布时间:2024-01-26 06:14:58.0

在这里插入图片描述


import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();//输入学生的个数int m = sc.nextInt();//输入习题个数int  j= 0;int[] goal = new int[m];//分数数组for (int i = 0; i < m; i++) {goal[i] = sc.nextInt();}int[] ok = new int[m];//答案数组for (int i = 0; i < m; i++) {ok[i] = sc.nextInt();}while (j < n) {int sum = 0;//记录得分int[] da = new int[m];//学生答案数组for (int i = 0; i < m; i++) {da[i] = sc.nextInt();}for (int i = 0; i < m; i++) {if (da[i] == ok[i]) {sum += goal[i];}}if (j<n-1)System.out.println(sum);elseSystem.out.print(sum);j++;}}
}

在这里插入图片描述

  相关解决方案