프로그래머스 백준 문제

백준 8958번

전한준 2024. 9. 2. 19:40

8958번: OX퀴즈 (acmicpc.net)

 

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        for(int i=0;i<n;i++){
            char[]tmp=br.readLine().toCharArray();
            int score=0;
            int result=0;
            for(int j=0;j<tmp.length;j++){
                if(tmp[j]=='O'){
                    score++;
                    result+=score;
                }
                else{
                    score=0;
                }
            }
            System.out.println(result);
        }

    }
}

 

char[]tmp=br.readLine().toCharArray() 이방식에 주목하자

 

'프로그래머스 백준 문제' 카테고리의 다른 글

백준 10816 숫자카드2  (0) 2025.06.16
백준 이분탐색 2512  (0) 2025.06.16
2920  (0) 2024.09.19
2577  (0) 2024.09.02
2667번 단지 번호 붙이기  (0) 2024.07.23