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

지극히 개인적인 개발블로그

백준 알고리즘 8958: OX퀴즈(C++) 본문

알고리즘

백준 알고리즘 8958: OX퀴즈(C++)

코드분쇄기 2019. 9. 19. 14:18

 

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	char input[80];
	int sum = 0;
	int correct = 0;
	int loop = 0;
	int n;
	cin >> n;

	while (n > loop)
	{
		cin >> input;

		for (int i = 0; i < strlen(input); i++)
		{
			if (input[i] == 'O')
			{
				correct++;
				sum += correct;
			}
			else
			{
				correct = 0;
			}
		}
		cout << sum << endl;
		sum = 0;
		correct = 0;
		loop++;
	}
}

strlen()함수가 생각안나서 더 복잡하게 풀었네요. 항상 기본에 충실해야 할것 같습니다.