UVa 1585 Score

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;
}
posted @ 2017-02-27 22:46  ssh_alitheia  阅读(72)  评论(0编辑  收藏  举报