3-1 (UVa 1585)
此题较为简单,记录连续读入O 的个数即可,代码如下
#include <stdio.h>
int main(void)
{
char store[105];
int T, flag = 0, score = 0, i;
scanf("%d", &T);
getchar();
while (T--)
{
fgets(store, 100, stdin);
for (i = 0; store[i] != '\n'; i++)
if (store[i] == 'O')
{
++flag;
score += flag;
}
else
flag = 0;
printf("%d\n", score);
score = 0;
flag = 0;
}
return 0;
}