Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
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
Archives
Today
Total
관리 메뉴

코딩로그

[백준/BOJ/C++] 9296번 Grading Exams 본문

YJ/C++

[백준/BOJ/C++] 9296번 Grading Exams

Team DAON 2021. 12. 27. 13:26

[문제]

Ms. Garrette needs help grading her multiple choice exams. To prevent cheating, she gave each student an individualized exam. She wants to write a program that, given an answer key and a particular student’s responses, calculates the number of incorrect answers. Can you help her?

[입력]

The first line of input is the number of test cases that follow. Each test case starts with an integer L (0 < L ≤ 100) representing the number of questions on the exam. The next line contains the answer key, where each question is represented by a single letter (i.e. a, b, c, or d) corresponding to the correct answer. The following line contains the student’s responses in the same format.

[출력]

For each case, output the line “Case x:” where x is the case number, on a single line. This is followed by the number of student responses that did not match the answer key.

[Source Code]

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int test;
	cin >> test;

	for(int i = 0; i< test; i++){
		int len, count = 0;
		string answer, correct;
		cin >> len >> answer >> correct;

		for(int j = 0; j < len; j++){
			if(answer[j] != correct[j])
				count++;
		}

		cout << "Case " << i+1 <<": " << count << "\n";
	}
}

[결과 화면]