Notice
Recent Posts
Recent Comments
Link
study record
백준 9093 - 스위프트 풀이 본문
let n: Int = Int(readLine()!)!
var str: String = ""
for _ in 0..<n {
let input = readLine()!
let arr = input.split(separator: " ")
for word in arr {
var wordStr = ""
for c in word {
wordStr = String(c) + wordStr
}
str += wordStr + " "
}
str += "\n"
}
print(str)
다른 사람의 깔끔한 풀이
let t = Int(readLine()!)!
for _ in 0..<t {
let words = readLine()!.split(separator: " ").map{String($0)}
var arr = [String]()
for word in words {
var temp = ""
for str in word.reversed() {
temp += String(str)
}
arr.append(temp)
}
let result = arr.joined(separator: " ")
print(result)
}
'알고리즘 > 스위프트 알고리즘' 카테고리의 다른 글
백준 2740 - 스위프트 풀이 (0) | 2022.02.06 |
---|---|
백준 1292 - 스위프트 풀이 (0) | 2022.02.04 |