Solution to the problem number 1585 of UVA - 1585.

Any questions do not hesitate to contact.

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a;
    cin>>a;
    while(a--)
    {
        int res=0,cont=1;
        string b;
        cin>>b;
        for(int i=0; i<b.length();i++)
        {
            if(b[i]=='O')
            {
                res+=cont;
                cont++;
            }
            else
                cont=1;
        }
        cout<<res<<endl;
    }
    return 0;
}

Don't miss anything.

Keep in touch with Isaac Lozano Osorio!