백준 알고리즘(C/C++) - 8958번 OX퀴즈
- 알고리즘
- 2021. 6. 9.
#include <stdio.h>
int main() {
int s, n, b;
char a[80];
scanf("%d", &n);
while (n--) {
b = s = 0;
scanf("%s", a);
for (int i = 0; a[i]; i++)
a[i] == 'O' ? s += ++b : (b = 0);
printf("%d\n", s);
}
}
#include <iostream>
int main() {
int s, n, b;
char a[80];
std::cin >> n;
while (n--) {
b = s = 0;
std::cin >> a;
for (int i = 0; a[i]; i++)
a[i] == 'O' ? s += ++b : (b = 0);
std::cout << s << std::endl;
}
}