코딩테스트

OX퀴즈(백준)

dofury 2023. 6. 29. 15:55
728x90

count = int(input())

for i in range(count):
    text = input()
    total_score = 0
    score = 0
    for t in text:
        if t == "O":
            total_score += score
            score+=1
        else:
            total_score += score
            score = 0
    total_score += score

    print(total_score)

반복할 횟수를 입력받고

텍스트를 하나씩 읽어들인다.

O가 나올경우 현재 점수를 최종 점수에 합산하고  점수를 누적한다.

X가 나올경우 현재 점수를 최종점수에 합산한고 점수를 초기화한다 .

 

728x90