算法竞赛入门经典 习题3-1
作者:互联网
UVa01585
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n = 0;
cin >> n;
string strAns;
for (int i = 0; i < n; i++)
{
cin >> strAns;
int consecutive = 0, score = 0;
for (auto c : strAns)
{
if (c == 'O'){
score++;
score += consecutive;
consecutive++;
}
else if(c == 'X'){
consecutive = 0;
}
}
cout << score << endl;
}
return 0;
}
/*
5
OOXXOXXOOO
OOXXOOXXOO
OXOXOXOXOXOXOX
OOOOOOOOOO
OOOOXOOOOXOOOOX
*/
标签:入门,int,strAns,++,算法,score,consecutive,习题,include 来源: https://blog.csdn.net/RayoNicks/article/details/100850136