PAT B1061 判断题(C++)

PAT甲级目录 | PAT乙级目录

题目描述

B1061 判断题

解题思路

逻辑题,该题选择结果与正确答案一致则得满分,否则得零分。

代码示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <cstdio>
int main(){
int N, M, score[110] = {0}, right_ans[110] = {0};
scanf("%d %d", &N, &M);
for(int i = 0; i < M; i++) scanf("%d", &score[i]);
for(int i = 0; i < M; i++) scanf("%d", &right_ans[i]);
for(int i = 0; i < N; i++){
int ans = 0, t;
for(int j = 0; j < M; j++){
scanf("%d", &t);
ans = ans + (t == right_ans[j]) * score[j];
}
printf("%d\n", ans);
}
return 0;
}