sicily 1324

#include "iostream"
#include "string"
using namespace std;
int main()
{
	int T;
	cin >> T;
	string *str = new string[T];
	for (int i = 0; i < T; i++)//字符串的输入
		cin >> str[i];
	for (int i = 0; i < T; i++)
	{
		int size = str[i].size();
		int sum = 0, m = 0;
		for (int j = 0; j < size; j++)
		{
			if (str[i][j] == 'O')//O的判断
			{
				sum += m + 1;
				m = m + 1;
			}
			if (str[i][j] == 'X')//X的判断,如果是X就将m的值置为0,当后面遇到O时候就又从1开始加起来
			{
				m = 0;
				continue;
			}
		}
		cout << sum << endl;
	}
}

 

你可能感兴趣的:(sicily 1324)