개발하는 자몽

[8958] 1차원 배열 - OX퀴즈 본문

Algorithm

[8958] 1차원 배열 - OX퀴즈

jaamong 2022. 3. 31. 14:24

문제

 

코드

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
    public static void main(String[] args) throws IOException {
        int total = 0;
        int temp = 0;
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        
        String quiz[] = new String[Integer.parseInt(br.readLine())];
        for(int i=0; i<quiz.length; i++){
            quiz[i] = br.readLine();
            
            for(int j=0; j<quiz[i].length(); j++){
                if(quiz[i].charAt(j) == 'O'){
                    temp++;
                } else {
                    temp = 0;
                } total+=temp;
            }
            sb.append(total).append('\n');
            total=0;
            temp=0;
        }
        System.out.println(sb);
    }
}
Comments