본문 바로가기

프로그래밍/백준

8958 OX퀴즈

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.*;
 
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] a = new String[n];
        int[] score = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.next();
        }
        for(int i=0; i<n; i++) {
            score[i]=0;
            int count=0;
            for(int j=0; j<a[i].length(); j++) {
                if(a[i].charAt(j) == 'O') {
                    count++;
                    score[i] += count;
                }
                else {
                    count = 0;
                }
            }
        }
        for(int i=0; i<n; i++) {
            System.out.println(score[i]);
        }
 
    }
}
cs


'프로그래밍 > 백준' 카테고리의 다른 글

10039 평균 점수  (0) 2017.10.14
2920 음계  (0) 2017.10.14
2577 숫자의 개수  (0) 2017.10.14
1152 단어의 개수  (0) 2017.10.07
백준 acm 2448 - 별찍기 (11)  (0) 2017.10.06