【习题 3-1 UVA

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

模拟水题

【错的次数】

在这里输入错的次数

【反思】

在这里输入反思

【代码】

#include <bits/stdc++.h>
using namespace std;

string s;

int main()
{
	/*freopen("F:\rush.txt", "r", stdin);*/
	int n;
	scanf("%d", &n);
	while (n--)
	{
		cin >> s;
		int len = s.size();
		long long ans = 0;
		for (int i = 0; i < len; i++)
		{
			if (s[i] == 'X') continue;
			int j = i;
			ans++;
			while (j + 1 < len && s[j + 1] == s[i])
			{
				j++;
				ans += (j - i + 1);
			}
			i = j;
		}
		printf("%lld
", ans);
	}
	return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/7659846.html