본문 바로가기

IT/알고리즘

백준 5단계(8958)

반응형
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
31
32
33
34
35
 
public class Main {
    
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        int max = 0;
        String[] strArr = new String[n];
        for(int i = 0; i < n; i++) {
            strArr[i] = br.readLine();
        }
        
        int[] totalArr = new int[n];
        for(int i = 0; i < n; i++) {
            int count = 0;
            for(int j = 0; j < strArr[i].length(); j++) {
                if(strArr[i].charAt(j) == 'X') count = 0;
                else count++;
                totalArr[i] += count;
            }
            bw.write(String.valueOf(totalArr[i]) + "\n");
        }
        bw.flush();
        
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
반응형

'IT > 알고리즘' 카테고리의 다른 글

백준 6단계(15596)  (0) 2019.12.07
백준 5단계(4344)  (0) 2019.11.28
백준 5단계(1546)  (0) 2019.11.28
백준 5단계(3052)  (0) 2019.11.28
백준 5단계(2577)  (0) 2019.11.28