티스토리 뷰
- 입력받은 문장의 각 단어를 뒤집어 출력해야 함 → reversed()
- 각 단어를 reversed 메서드를 이용해 뒤집고 빈 문자열 result에 추가
- 단어 사이에 공백 추가할것
//
// main.swift
// Algorithm Swift
// BaekJoon
// 9093 - 단어 뒤집기
import Foundation
let N = Int(readLine()!)!
for _ in 0...(N-1) {
let input = readLine()!.split(separator: " ").map{ String($0) }
var result: String = ""
for char in input{
result += char.reversed() + " "
}
print(result)
}
'Algorithm > 백준' 카테고리의 다른 글
[BOJ] (Swift) 10845 - 큐 (0) | 2022.08.01 |
---|---|
[BOJ] (Swift) 1406 - 에디터 (0) | 2022.08.01 |
[BOJ] (Swift) 1874 - 스택 수열 (0) | 2022.07.31 |
[BOJ] (Swift) 9012 - 괄호 (0) | 2022.07.28 |
[BOJ] (Swift) 10828 - 스택 (0) | 2022.07.28 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- BOJ 17298
- Gradient View
- 2023 회고
- ios
- swift
- github
- bottom sheet
- crud
- BOJ 10799
- Algorithm
- BOJ 17413
- Sheet Height
- Card CollectionVIew
- UICollectionView Error
- Stack
- sheetPresentationController
- BOJ 10808
- 1406 에디터
- CAGradientLayer
- autolayout
- BOJ 10866
- Carousel Effect
- Custom Detent
- UICollectionView banner
- BOJ 10820
- BOJ 1935
- git
- NaverMaps
- BOJ 10809
- 요시푸스
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함