백준: 8958(OX퀴즈)

강지안·2023년 6월 25일
0

baekjoon

목록 보기
72/186

문제

코드

import java.util.Scanner;

public class q8958 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.nextLine());
        int[] scores = new int[N];

        for(int i=0; i<N; i++) {
            int score = 0;
            int count = 0;
            String[] OX = sc.nextLine().split("");

            for(int j=0; j< OX.length; j++) {
                if(OX[j].equals("O")) {
                    score += ++count;
                } else {
                    count = 0;
                }
            }
            scores[i] = score;
        }

        for(int i=0; i<N; i++) {
            System.out.println(scores[i]);
        }
    }
}

0개의 댓글