PAT B brush road title 1061 title determination (15 minutes)

Analyzing title 1061 (15 minutes)

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. 5. 4. 3. 3. 1
0 0 0. 1. 1. 1
0 0 0. 1. 1. 1
. 1. 1 0 0 0. 1
. 1. 1. 1. 1 0 0

Output Sample:
13 is
. 11
12 is

#include <iostream> 
using namespace std;

int main()
{
	int N,M;
	cin>>N>>M;
	int grade[M],answer[M],student[N][M];
	int i,j;
	for(i=0;i<M;i++){
		cin>>grade[i];
	}
	for(i=0;i<M;i++){
		cin>>answer[i];
	}
	for(i=0;i<N;i++){
		for(j=0;j<M;j++){
			cin>>student[i][j];
		}
	}
	int sum[N]={0};
	for(i=0;i<N;i++){
		for(j=0;j<M;j++){
			if(student[i][j]==answer[j]){
				sum[i]+=grade[j];	
			}
		}
	}
	for(i=0;i<N;i++){
		cout<<sum[i]<<endl;
	}
	return 0;
}
Published 73 original articles · won praise 0 · Views 527

Guess you like

Origin blog.csdn.net/derbi123123/article/details/103827861