[BOJ]백준 8958번: OX퀴즈 (baekjoon 8958)

(BOJ)백준 8958 - 8958번: OX퀴즈

8958번: OX퀴즈

코드

import java.io.*;

public class B8958 {
    static int N, continuous, score;
    static String in;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        N = Integer.parseInt(br.readLine());
        for (int i = 0; i < N; i++) {
            in = br.readLine();
            continuous = 0;score = 0;
            for (int j = 0; j < in.length(); j++) {
                score += (in.charAt(j) == 'O') ? continuous + 1 : 0;
                continuous = (in.charAt(j) == 'O') ? continuous + 1 : 0;
            }
            bw.write(score + "\n");
            bw.flush();
        }
        bw.close();
    }
}

설명