批改多选题是比较麻烦的事情,有很多不同的计分方法。有一种最常见的计分方法是:如果考生选择了部分正确选项,并且没有选择任何错误选项,则得到 50% 分数;如果考生选择了任何一个错误的选项,则不能得分。本题就请你写个程序帮助老师批改多选题,并且指出哪道题的哪个选项错的人最多。
输入格式:
输入在第一行给出两个正整数 N(≤1000)和 M(≤100),分别是学生人数和多选题的个数。随后 M 行,每行顺次给出一道题的满分值(不超过 5 的正整数)、选项个数(不少于 2 且不超过 5 的正整数)、正确选项个数(不超过选项个数的正整数)、所有正确选项。注意每题的选项从小写英文字母 a 开始顺次排列。各项间以 1 个空格分隔。最后 N 行,每行给出一个学生的答题情况,其每题答案格式为 (选中的选项个数 选项1 ……),按题目顺序给出。注意:题目保证学生的答题情况是合法的,即不存在选中的选项数超过实际选项数的情况。
输出格式:
按照输入的顺序给出每个学生的得分,每个分数占一行,输出小数点后 1 位。最后输出错得最多的题目选项的信息,格式为:错误次数 题目编号(题目按照输入的顺序从1开始编号)-选项号。如果有并列,则每行一个选项,按题目编号递增顺序输出;再并列则按选项号递增顺序输出。行首尾不得有多余空格。如果所有题目都没有人错,则在最后一行输出 Too simple。
输入样例 1:
3 4
3 4 2 a c
2 5 1 b
5 3 2 b c
1 5 4 a b d e
(2 a c) (3 b d e) (2 a c) (3 a b e)
(2 a c) (1 b) (2 a b) (4 a b d e)
(2 b d) (1 e) (1 c) (4 a b c d)
输出样例 1:
3.5
6.0
2.5
2 2-e
2 3-a
2 3-b
输入样例 2:
2 2
3 4 2 a c
2 5 1 b
(2 a c) (1 b)
(2 a c) (1 b)
输出样例 2:
5.0
5.0
Too simple
C:
#include<stdio.h>
int main()
{
int n,m,i,j,k,p,max,flag,manfen[100],numxx[100],numzq[100],cuowu[100][5]={0},biaoji[100][5]={0};
double sum[1000]={0};
char c,s[100][5];
scanf("%d %d",&n,&m);
for(i=0;i<m;i++)
{
scanf("%d %d %d",&manfen[i],&numxx[i],&numzq[i]);
j=0;
while((c=getchar())!='\n')
{
if(c!=' ')s[i][j++]=c;
}
}
for(i=0;i<n;i++) //第i个学生
{
j=0; //第j道题
while((c=getchar())!='\n') //此时c应等于'('
{
flag=1;
scanf("%d",&p); //学生第j道题的答题个数
while((c=getchar())!=')') //此时c应为空格
{
if(c!=' ')
{
for(k=0;k<numzq[j];k++) //第k个正确选项
{
if(c==s[j][k])
{
biaoji[j][k]=1; //把学生选项中选到的正确答案标记一下
break;
}
}
if(k==numzq[j])
{
flag=0; //答错一个选项得零分的标记
cuowu[j][c-97]++;
}
}
}
for(k=0;k<numzq[j];k++)
{
if(biaoji[j][k]==0)cuowu[j][s[j][k]-97]++; //把学生选项没选的正确选项进行计数
}
for(k=0;k<5;k++) biaoji[j][k]=0; //把标记数组重新置零复位,方便下一轮的标记
if(p==numzq[j]&&flag==1)sum[i]+=manfen[j];
if(p<numzq[j]&&flag==1)sum[i]+=(double)manfen[j]/2;
//printf("i=%d,p=%d,flag=%d,sum=%lf\n",i,p,flag,sum[i]);
if(j<m-1) getchar();
j++;
}
}
for(i=0;i<n;i++)printf("%.1lf\n",sum[i]);
for(i=0,max=0;i<m;i++)
{
for(j=0;j<5;j++)
{
if(cuowu[i][j]>max)max=cuowu[i][j];
}
}
if(max==0)
{
printf("Too simple\n");
return 0;
}
for(i=0;i<m;i++)
{
for(j=0;j<5;j++)
{
if(cuowu[i][j]==max)printf("%d %d-%c\n",max,i+1,j+97);
}
}
return 0;
}
C++:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n, m, i, j, k, p, max, flag;
int manfen[100], numxx[100], numzq[100], cuowu[100][5] = {0}, biaoji[100][5] = {0};
double sum[1000] = {0};
char c, s[100][5];
cin >> n >> m;
for (i = 0; i < m; i++)
{
cin >> manfen[i] >> numxx[i] >> numzq[i];
j = 0;
while ((c = getchar()) != '\n')
{
if (c != ' ')
s[i][j++] = c;
}
}
for (i = 0; i < n; i++) //第i个学生
{
j = 0; //第j道题
while ((c = getchar()) != '\n') //此时c应等于'('
{
flag = 1;
cin >> p; //学生第j道题的答题个数
while ((c = getchar()) != ')') //此时c应为空格
{
if (c != ' ')
{
for (k = 0; k < numzq[j]; k++) //第k个正确选项
{
if (c == s[j][k])
{
biaoji[j][k] = 1; //把学生选项中选到的正确答案标记一下
break;
}
}
if (k == numzq[j])
{
flag = 0; //答错一个选项得零分的标记
cuowu[j][c - 97]++;
}
}
}
for (k = 0; k < numzq[j]; k++)
{
if (biaoji[j][k] == 0)
cuowu[j][s[j][k] - 97]++; //把学生选项没选的正确选项进行计数
}
for (k = 0; k < 5; k++)
biaoji[j][k] = 0; //把标记数组重新置零复位,方便下一轮的标记
if (p == numzq[j] && flag == 1)
sum[i] += manfen[j];
if (p < numzq[j] && flag == 1)
sum[i] += (double)manfen[j] / 2;
if (j < m - 1)
getchar();
j++;
}
}
for (i = 0; i < n; i++)
cout << fixed << sum[i] << endl;
for (i = 0, max = 0; i < m; i++)
{
for (j = 0; j < 5; j++)
{
if (cuowu[i][j] > max)
max = cuowu[i][j];
}
}
if (max == 0)
{
cout << "Too simple" << endl;
return 0;
}
for (i = 0; i < m; i++)
{
for (j = 0; j < 5; j++)
{
if (cuowu[i][j] == max)
cout << max << " " << i + 1 << "-" << char(j + 97) << endl;
}
}
return 0;
}
Java:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int[] manfen = new int[100];
int[] numxx = new int[100];
int[] numzq = new int[100];
int[][] cuowu = new int[100][5];
int[][] biaoji = new int[100][5];
double[] sum = new double[1000];
char[][] s = new char[100][5];
for (int i = 0; i < m; i++) {
manfen[i] = scanner.nextInt();
numxx[i] = scanner.nextInt();
numzq[i] = scanner.nextInt();
scanner.nextLine();
String line = scanner.nextLine();
int j = 0;
for (char c : line.toCharArray()) {
if (c != ' ')
s[i][j++] = c;
}
}
for (int i = 0; i < n; i++) {
int j = 0;
while (scanner.hasNext()) {
char c = scanner.next().charAt(0);
if (c == '(') {
int flag = 1;
int p = scanner.nextInt();
while (scanner.hasNext()) {
char answer = scanner.next().charAt(0);
if (answer == ')') {
break;
} else if (answer != ' ') {
for (int k = 0; k < numzq[j]; k++) {
if (answer == s[j][k]) {
biaoji[j][k] = 1;
break;
}
}
if (k == numzq[j]) {
flag = 0;
cuowu[j][answer - 97]++;
}
}
}
for (int k = 0; k < numzq[j]; k++) {
if (biaoji[j][k] == 0)
cuowu[j][s[j][k] - 97]++;
}
for (int k = 0; k < 5; k++)
biaoji[j][k] = 0;
if (p == numzq[j] && flag == 1)
sum[i] += manfen[j];
if (p < numzq[j] && flag == 1)
sum[i] += (double) manfen[j] / 2;
j++;
}
}
}
for (int i = 0; i < n; i++)
System.out.println(String.format("%.1f", sum[i]));
int max = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < 5; j++) {
if (cuowu[i][j] > max)
max = cuowu[i][j];
}
}
if (max == 0) {
System.out.println("Too simple");
return;
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < 5; j++) {
if (cuowu[i][j] == max)
System.out.println(max + " " + (i + 1) + "-" + (char) (j + 97));
}
}
}
}
Python:
n, m = map(int, input().split())
manfen = [0] * 100
numxx = [0] * 100
numzq = [0] * 100
cuowu = [[0] * 5 for _ in range(100)]
biaoji = [[0] * 5 for _ in range(100)]
sum_scores = [0] * 1000
s = [[''] * 5 for _ in range(100)]
for i in range(m):
manfen[i], numxx[i], numzq[i] = map(int, input().split())
line = input().replace(' ', '')
j = 0
for c in line:
if c != ' ':
s[i][j] = c
j += 1
for i in range(n):
j = 0
while True:
c = input()[0]
if c == '(':
flag = 1
p = int(input())
while True:
answer = input()[0]
if answer == ')':
break
elif answer != ' ':
for k in range(numzq[j]):
if answer == s[j][k]:
biaoji[j][k] = 1
break
if k == numzq[j]:
flag = 0
cuowu[j][ord(answer) - 97] += 1
for k in range(numzq[j]):
if biaoji[j][k] == 0:
cuowu[j][ord(s[j][k]) - 97] += 1
for k in range(5):
biaoji[j][k] = 0
if p == numzq[j] and flag == 1:
sum_scores[i] += manfen[j]
if p < numzq[j] and flag == 1:
sum_scores[i] += manfen[j] / 2
j += 1
else:
break
for score in sum_scores:
print(f'{score:.1f}')
max_count = max(max(cuowu[i]) for i in range(m))
if max_count == 0:
print('Too simple')
else:
for i in range(m):
for j in range(5):
if cuowu[i][j] == max_count:
print(f'{max_count} {i+1}-{chr(j+97)}')
博客介绍了一种常见的多选题计分方法,即选部分正确且无错误选项得 50% 分数,选错误选项不得分。还给出了输入输出格式及样例,要求编写程序帮助老师批改多选题,并指出哪道题的哪个选项错的人最多,涉及 C、C++、Java、Python 等语言。
6105

被折叠的 条评论
为什么被折叠?



