sicily--1324. Score

水题;记得在重新出现“X”后, 权值变为1即可

#include<iostream>
#include<string>
using namespace std;

int main()
{
    int testNum;
    cin >> testNum;
    while(testNum != 0)
    {
        string s;
        int score = 0;
        int weight = 1;
        cin >> s;
        int len = s.length();
        for(int i = 0; i < len; i++)
        {
            if(s[i] == 'x' || s[i] == 'X')
            {
                weight = 1;
            }
            else
            {
                score = score + weight;
                weight++;
            }
        }
    
        cout << score << endl;
        testNum--;
        
    }
    return 0;
    
}                                 


你可能感兴趣的:(String)