Algorithm/백준
백준 8958번: OX퀴즈
hmhmchm
2021. 8. 31. 12:12
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Baekjoon_OX퀴즈 {
static int N;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(in.readLine());
for (int i = 0; i < N; i++) {
String[] str = in.readLine().split("");
int cnt = 0;
int res = 0;
for (int j = 0; j < str.length; j++) {
if (str[j].equals("O")) {
cnt++;
}
if (str[j].equals("X")) {
cnt = 0;
}
res += cnt;
}
System.out.println(res);
}
}
}
728x90