Programming/백준
[백준] 8958 - OX퀴즈 (파이썬) (C++)
pental
2020. 4. 9. 14:08
N = int(input())
for i in range(N):
score = 0
cnt = 0
result = input()
for j in range(len(result)):
if result[j] == 'O':
cnt += 1
score += cnt
elif result[j] == 'X':
score += 0
cnt = 0
print(score)
#include <iostream>
#include <string>
using namespace std;
int main() {
int num;
cin >> num;
int *save_total = new int[num];
for (int i = 0; i < num; i++) {
string answer;
int count = 0;
int total = 0;
cin >> answer;
for (int j = 0; j < answer.size(); j++) {
if (answer.at(j) == 'O') {
count++;
}
else {
count = 0;
}
total += count;
}
cout << total<< "\n";
}
}