repeating, count 를 통해 문자열 반복 출력이 가능하다.
import Foundation
let input = readLine()!.components(separatedBy: [" "]).map { $0 }
let (str, n) = (input[0], Int(input[1])!)
print(String(repeating: str, count: n))
'Swift > Swift Codingtest' 카테고리의 다른 글
[Swift] 백준 5618 공약수 (0) | 2023.04.06 |
---|---|
[Swift] 백준 14425번 문자열 집합 (0) | 2023.04.05 |
[Swift] 백준풀이를 위한 Queue (0) | 2023.04.05 |
[Swift] 백준 1620번 나는야 포켓몬 마스터 이다솜 (0) | 2023.04.04 |
[Swift] 백준 2164 카드2 (0) | 2023.03.27 |