백준 - 8958 OX 퀴즈

AekT·2021년 10월 24일
0

단계별로풀어보기

목록 보기
9/11
post-thumbnail

백문 8958 OX 퀴즈

문제 : https://www.acmicpc.net/problem/8958

Swift :

let t = Int(readLine()!)!

var res = 0
var plus = 0
for _ in 0..<t{
    res = 0
    plus = 0
    let input = readLine()!
    for i in input.map{String($0)} {
        if i == "O"{
            plus += 1
            res += plus
        }else{
            plus = 0
        }
    }
    print(res)
}
profile
으악

0개의 댓글