Notice
Recent Posts
Recent Comments
Link
«   2025/10   »
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++] 16018번 Occupy parking 본문

YJ/C++

[백준/BOJ/C++] 16018번 Occupy parking

Team DAON 2021. 11. 2. 17:18

[문제]

You supervise a small parking lot which has N parking spaces.

Yesterday, you recorded which parking spaces were occupied by cars and which were empty.

Today, you recorded the same information.

How many of the parking spaces were occupied both yesterday and today?

[입력]

The first line of input contains the integer N (1 ≤ N ≤ 100). The second and third lines of input contain N characters each. The second line of input records the information about yesterday’s parking spaces, and the third line of input records the information about today’s parking spaces. Each of these 2N characters will either be C to indicate an occupied space or . to indicate it was an empty parking space.

[출력]

Output the number of parking spaces which were occupied yesterday and today.

[Source Code]

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


int main() {
	string yesterday, today;
	int num;
	cin >> num >> yesterday >> today;
	int count = 0;

	for(int i = 0; i < num; i++){
		if(yesterday[i] == 'C' && today[i] == 'C')
			count++;
	}

	cout << count;
}

[결과 화면]

'YJ > C++' 카테고리의 다른 글

[백준/BOJ/C++] 9699번 RICE SACK  (0) 2021.11.02
[백준/BOJ/C++] 13985번 Equality  (0) 2021.11.02
[백준/BOJ/C++] 14782번 Bedtime Reading, I  (0) 2021.11.02
[백준/BOJ/C++] 11506번 占쏙옙  (0) 2021.11.02
[백준/BOJ/C++] 10810번 공 넣기  (0) 2021.11.02