티스토리 뷰
- 입력받은 문장의 각 단어를 뒤집어 출력해야 함 → 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
- swift
- BOJ 17413
- 1406 에디터
- BOJ 1935
- NaverMaps
- Card CollectionVIew
- Algorithm
- CAGradientLayer
- Gradient View
- github
- bottom sheet
- BOJ 10808
- autolayout
- BOJ 17298
- Custom Detent
- git
- BOJ 10820
- BOJ 10866
- Stack
- UICollectionView banner
- sheetPresentationController
- BOJ 10799
- BOJ 10809
- Carousel Effect
- UICollectionView Error
- 요시푸스
- 2023 회고
- Sheet Height
- ios
- crud
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
글 보관함