-
Notifications
You must be signed in to change notification settings - Fork 1
/
2011 S2.cpp
50 lines (31 loc) · 951 Bytes
/
2011 S2.cpp
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
/*
2011 S2 - Multiple Choice
Difficulty: Very Easy
Ad Hoc Problem
Store student answers and correct answers in seperate arrays. Compare the two arrays and count the total number of matching elements.
*/
#include <iostream>
#include <vector>
int main(){
int N;
std::cin >> N;
std::vector<char> student_answers (N), correct_answers (N); //For storing the answers
//Collecting student answers
for (int i = 0; i < N; i++){
std::cin >> student_answers[i];
}
//Collecting the correct test answers
for (int i = 0; i < N; i++){
std::cin >> correct_answers[i];
}
int score = 0; //Keep track of how many correct answers the student has
//Check if the student answered correctly
for (int i = 0; i < N; i++){
if (student_answers[i] == correct_answers[i]){
score++;
}
}
//Output student score
std::cout << score << std::endl;
return 0;
}