본문 바로가기

BOJ

[백준] 8958번 OX퀴즈 c++

#include <iostream>
using namespace std;

int main(void) {
	ios::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	int num;
	int sum = 0;
	int count = 0;
	string test;
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> test;
		for (int j = 0; j < test.length(); j++) {
			if (test[j] == 'O') {
				count++;
				sum += count;
			}
			else {
				count = 0;
			}
		}
		cout << sum << "\n";
		count = 0;
		sum = 0;
	}
	return 0;
}

'BOJ' 카테고리의 다른 글

[백준] 1152번 단어의 개수 c++  (0) 2020.04.26
[백준] 1157번 단어공부 c++  (0) 2020.04.26
[백준] 10996번 별 찍기 -21 c++  (0) 2020.04.26
[백준] 1110번 더하기 사이클 c++  (0) 2020.04.26
[백준] 5543번 상근날드 c++  (0) 2020.04.26