得分(UVa1585)
题目具体描述见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4460
C++11代码如下:
1 #include<iostream> 2 #include<string.h> 3 using namespace std; 4 #define maxn 85 5 char s[maxn]; 6 int main() { 7 int T; 8 cin >> T; 9 while (T--) { 10 cin >> s; 11 int sum = 0, count = 1; 12 int n = strlen(s); 13 for (int i = 0; i < n; i++) { 14 if (s[i] == 'O') { 15 sum += count; 16 count++; 17 } 18 else count = 1; 19 } 20 cout << sum << endl; 21 } 22 return 0; 23 }