백준 8958번: OX퀴즈
2021. 8. 31. 12:12ㆍAlgorithm/백준
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
'Algorithm > 백준' 카테고리의 다른 글
백준 11726번: 2xn 타일링 (0) | 2021.09.15 |
---|---|
백준 2133번 : 타일 채우기 (java) (0) | 2021.09.15 |
백준 3052번: 나머지 (0) | 2021.08.31 |
백준 10163번 : 색종이 (java) (0) | 2021.08.25 |
백준 11399번: ATM (java) (0) | 2021.08.24 |