1061-判断题
leenickzh Lv4

判断题的评判很简单,本题就要求你写个简单的程序帮助老师判题并统计学生们判断题的得分.

输入格式

输入在第一行给出两个不超过100的正整数NM,分别是学生人数和判断题数量.第二行给出M个不超过5的正整数,是每道题的满分值.第三行给出每道题对应的正确答案,0代表“非”,1代表“是”.随后N行,每行给出一个学生的解答.数字间均以空格分隔.

输出格式

按照输入的顺序输出每个学生的得分,每个分数占一行.

输入样例

1
2
3
4
5
6
3 6
2 1 3 3 4 5
0 0 1 0 1 1
0 1 1 0 0 1
1 0 1 0 1 0
1 1 0 0 1 1

输出样例

1
2
3
13
11
12

分析

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <vector>
using namespace std;

struct stu
{
vector<int> stuAnswer;
int score;
};

void readFullScorePerT(int M,vector<int> &fullScores)
{
for(int i = 0;i<M;i++)
{
int temp;
cin>>temp;
fullScores.push_back(temp);
}
}

void readCorectAnswer(int M,vector<int> &corects)
{
for(int i = 0;i<M;i++)
{
int temp;
cin>>temp;
corects.push_back(temp);
}
}

stu readStuAnswer(int M)
{
stu stu;
stu.score = 0;
for(int i = 0;i<M;i++)
{
int temp;
cin>>temp;
stu.stuAnswer.push_back(temp);
}
return stu;
}

int main()
{
int N, M;
cin>>N>>M;
vector<int> fullScores;
vector<int> corects;
vector<stu> stus;
readFullScorePerT(M,fullScores);
readCorectAnswer(M,corects);
for(int i = 0;i<N;i++)
{
stus.push_back(readStuAnswer(M));
}
for(int i = 0;i<N;i++)
{
for (int j = 0; j < M; ++j) {
if(stus[i].stuAnswer[j]==corects[j])
{
stus[i].score+=fullScores[j];
}else{
stus[i].score+=0;
}
}
}
for(int i = 0;i<N;i++)
{
cout<<stus[i].score<<endl;
}
return 0;
}
  • Post title:1061-判断题
  • Post author:leenickzh
  • Create time:2021-05-01 16:06:16
  • Post link:https://nickk.cn/2021/05/01/1061-判断题/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments