UVa1585 Score

#include <stdio.h>

int main()
{
    int T, O, score;
    char str[81], *p;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%s", str);
        O = score = 0;
        for (p = str; *p; ++p)
        {
            if (*p == 'O')
            {
                ++O;
                score += O;
            }
            else
            {
                O = 0;
            }
        }
        
        printf("%d ", score);
    }

    return 0;
}

原文地址:https://www.cnblogs.com/danny1221/p/4591273.html