题
要点:
计数器
重复出现加1
mycode
#include <stdio.h>
#include <string.h>
int main()
{
int T;
scanf("%d", &T);
for (int i = 0; i < T; i++)
{
char s[81];
scanf("%s", s);
int len = strlen(s);
int score = 0, count = 1;//count记录连续数个数
for (int j = 0; j < len; j++)
{
if (s[j] == 'O')
{
score += count;
count += 1;
}
else
{
count = 1;
}
}
printf("%d
", score);
}
return 0;
}