남극
백준 8958 OX 퀴즈 - Java 본문
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Baekjoon8958 {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String s = bf.readLine();
int result = 0;
int cnt = 0;
String[] arr = {};
int n = Integer.parseInt(s);
String[] l = new String[n+1];
for (int i = 0; i < n; i++) {
cnt = 0;
result = 0;
l[i] = bf.readLine();
for (int j = 0; j < l[i].length(); j++) {
if (l[i].charAt(j)=='O') {
cnt++;
} else {
cnt = 0;
}
result += cnt;
}
System.out.println(result);
}
}
}
'algorithm' 카테고리의 다른 글
백준 4673 셀프넘버 (Java) (0) | 2020.02.24 |
---|---|
백준 15596 정수 n개의 합 - Java (0) | 2020.02.22 |
백준 1546 평균 - java (0) | 2020.02.20 |
백준 3052 나머지 - Java (0) | 2020.02.20 |
백준 2577 (Java) (0) | 2020.02.20 |
Comments