https://pintia.cn/problem-sets/994805260223102976/problems/994805268817231872
#include <iostream>
using namespace std;
int main(){
int N, M, score[100] = {0}, answer[100] = {0};
cin >> N >> M;
for(int i = 0; i < M; i++)
cin >> score[i];
for(int i = 0; i < M; i++)
cin >> answer[i];
for(int i = 0; i < N; i++){
int sum = 0, tmp;
for(int j = 0; j < M; j++){
cin >> tmp;
if(!(tmp^answer[j]))
sum += score[j];
}
cout << sum << endl;
}
return 0;
}
本文提供了一段C++代码示例,该程序用于解决一项编程竞赛题目:根据输入的答题得分和正确答案,计算并输出每位参赛者的总分。通过使用数组存储得分和答案,再对比每位参赛者的答题情况来实现计分。

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



