UVa 1585 Score
题
要点:
计数器
重复出现加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\n", score);
}
return 0;
}
本文来自博客园,作者:ssh_alitheia,转载请注明原文链接:https://www.cnblogs.com/shanchuan/p/8150297.html