Notice
Recent Posts
Recent Comments
Link
«   2024/12   »
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
Tags
more
Archives
Today
Total
관리 메뉴

main

[백준-8959번/Java] OX 퀴즈 본문

Algorithm

[백준-8959번/Java] OX 퀴즈

1984 2022. 11. 10. 18:07
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.nextLine());
		
		for (int i = 0; i < N; i++) {

			int point = 1;
			int sum = 0;

			String str = sc.nextLine();

			for (char c : str.toCharArray()) {
				if (c == 'O') {
					sum += point;
					point++;
				} else if (c == 'X') {
					point = 1;
				}
			}
			System.out.println(sum);
		}

		sc.close();
	}

}
728x90

'Algorithm' 카테고리의 다른 글

[백준-1157번/Java] 단어공부  (0) 2022.11.10
[백준-4344번/Java] 평균은 넘겠지  (0) 2022.11.10
[백준-3052번/Java] 나머지  (0) 2022.11.10
[백준-15552번/Java] 빠른 A+B  (0) 2022.11.10
[백준-10757번/Java] 큰 수 A + B  (0) 2022.11.10
Comments