백준 - 1259 펠린드롬수

AekT·2021년 11월 7일
post-thumbnail

백준 1259 펠린드롬수

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

Swift :

var input = readLine()!

while input != "0"{
    print(isPalin(input) ? "yes" : "no")
    input = readLine()!
}


func isPalin(_ str: String) -> Bool{
    let arr = str.map{String($0)}
    var res = true
    for i in 0..<arr.count/2{
        if arr[i] != arr[arr.count-1-i]{
            res = false
        }
    }
    return res
}
profile
으악

0개의 댓글