Click on the link full solution summary PAT B -AC
Topic:
True or False judgment is very simple, this question requires you to write a simple program to help teachers judge students questions and statistical judge's scoring title.
Input format:
Enter two given positive integer of not more than 100 N and M in the first row, respectively, and determines whether the number is the number of students problems. The second row of M gives a positive integer not exceeding 5, is out of the value for each question. The third line corresponding to each question is given the correct answer, 0 stands for "not", 1 for "yes." Then N lines, each student is given a solution. Between numbers are separated by spaces.
Output format:
The output of each student's scores in the order entered, each score per line.
Sample input:
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
Sample output:
13
11
12
My code:
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstring>
#include<sstream>
using namespace std;
//有的时候题目是一起做的,所以会有不需要的头文件
int main()
{
int N,M;
cin>>N>>M;
int score[M]={0};
for(int i=0;i<M;i++)
{
scanf("%d",&score[i]);
}
int key[M]={0};
for(int i=0;i<M;i++)
{
scanf("%d",&key[i]);
}
for(int i=0;i<N;i++)
{
int sum=0;
for(int j=0;j<M;j++)
{
int t;
cin>>t;
if(t==key[j])sum+=score[j];
}
cout<<sum<<endl;
}
return 0;
}