일상

8958 : OX퀴즈

STUDYING,,, 2021. 7. 29. 00:41
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int TC = sc.nextInt();
		sc.nextLine();
		String str = null;

		for (int i = 0; i < TC; i++) {
			char tmp;
			int cnt = 0;
			int sum = 0;

			str = sc.nextLine();
			for (int k = 0; k < str.length(); k++) {
				tmp = str.charAt(k);
				if (tmp == 'O') {
					++cnt;
					sum += cnt;
				} else if (tmp == 'X') {
					cnt = 0;
					continue;
				}
			}

			System.out.println(sum);

		}

	}
}

'일상' 카테고리의 다른 글

15596 : 정수 N개의 합  (0) 2021.08.04
4344 : 평균은 넘겠지  (0) 2021.07.29
1546 : 평균  (0) 2021.07.28
3052 : 나머지  (0) 2021.07.28
2577 : 숫자의 개수  (0) 2021.07.27