알고리즘

C++ 알고리즘 - 백준 8958 OX퀴즈

마루설아 2024. 12. 14. 14:59

https://www.acmicpc.net/problem/8958

 

#include <iostream>
using namespace std;

string str[10000];

int main(void) {
	// C++ Init
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int c;
	int cnt = 0;
	int score = 0;

	cin >> c;

	for (int i = 0; i < c; i++) {
		cin >> str[i];
	}

	for (int i = 0; i < c; i++) {
		for (int j = 0; j < str[i].length(); j++) {
			if (str[i][j] == 'O') {
				cnt++;
				score += cnt;
			}

			else cnt = 0;
		}
		
		cout << score << endl;
		cnt = 0;
		score = 0;
	}
}