Don't Look Back In Anger

백준 8958번. OX퀴즈 본문

IT/백준

백준 8958번. OX퀴즈

버로나 2022. 5. 1. 20:03

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);

		String array[] = new String[scanner.nextInt()];
		for(int i=0; i<array.length; i++) {
			array[i] = scanner.next();
		}
		scanner.close();

		for(int i=0; i<array.length; i++) {
			int count=0;
			int sum=0;

			for(int j=0; j<array[i].length(); j++) {
				if(array[i].charAt(j) == 'O') {
					count++;
				}
				else {
					count=0;
				}
				sum += count;
			}
			System.out.println(sum);
		}

	}
}

'IT > 백준' 카테고리의 다른 글

백준 15552번. 빠른 A+B  (0) 2022.05.02
백준 2355번. 시그마  (0) 2022.04.26