코딩 공부/C++
백준 8958 C++
recordmastd
2023. 3. 5. 16:37
#include <iostream>
using namespace std;
int main()
{
int t;
string result;
cin >> t;
for (int i = 0; i < t; i++)
{
cin >> result;
int count = 0; // for문 안에서 count, sum 초기화
int sum = 0;
for (int j = 0; j < result.length(); j++)
{
if (result[j] == 'O')
count++;
else
count = 0;
sum += count;
}
cout << sum << endl;
}
return 0;
}