요구능력 : replacingOuccurrences
코드설명 : 받은 문자열 안에 크로아티아 문자 전부다 넣어보면서 있으면 변경해주는 건데, "dz="은 앞쪽에 있어야 "z="으로 안걸러진다.
후기 : 도저히 모르겠어서 구글링 해봤는데 함수하나알면 Clear...
import Foundation
var word = readLine()!
let m = ["c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z="]
for i in 0...m.count - 1 {
word = word.replacingOccurrences(of: m[i], with: "a")
}
print("\(word.count)")
'Algorithm > 문제풀이_백준' 카테고리의 다른 글
Swift) 백준 10872번 (0) | 2021.07.31 |
---|---|
Swift) 백준 1316번 (0) | 2021.07.31 |
Swift) 백준 2908번 (0) | 2021.07.29 |
Swift) 백준 1152번 (0) | 2021.07.28 |
Swift) 백준 1157번 (0) | 2021.07.28 |
댓글