코딩로그
[백준/BOJ/C++] 9296번 Grading Exams 본문
[문제]
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";
}
}
[결과 화면]
'YJ > C++' 카테고리의 다른 글
[백준/BOJ/C++] 2712번 미국 스타일 (0) | 2021.12.27 |
---|---|
[백준/BOJ/C++] 13234번 George Boole (0) | 2021.12.27 |
[백준/BOJ/C++] 10984번 내 학점을 구해줘 (0) | 2021.12.22 |
[백준/BOJ/C++] 11945번 뜨거운 붕어빵 (0) | 2021.12.22 |
[백준/BOJ/C++] 11575번 Affine Cipher (0) | 2021.12.22 |