欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

UVa-1585 - Score

程序员文章站 2022-06-09 16:47:54
...

UVa-1585 - Score

     题解:循环统计连续的O将对应的分数加上即可。

     AC代码:

#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 87;
#define _for(i,a,b) for(int i=a;i<=b;i++)
char s[maxn];
int ans,n;
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        scanf("%s",s);
        int leng = strlen(s);
        int last = 1;
        int sum = 0;
        _for(i,0,leng-1)
        {
            if(s[i]=='O')
            {
                sum+=last;
                last++;
            }
            else last = 1;
        }
        printf("%d\n",sum);
    }
    return 0;
}