๋ฐ์ํ
๋ฌธ์ ๋งํฌ
https://www.acmicpc.net/problem/11656
๋ด๊ฐ ํผ ํ์ด
- for๋ฌธ์ ํ์ฉํ์ฌ ํ๊ธ์์ฉ ๋นผ๊ณ stringํํ์ธ word ๋ณ์์ ๋ฃ์ด์ค๋ค. abc -> bc -> c
- word ๋ณ์ ์ ๋ถ๋ฅผ answer ๋ฐฐ์ด์ push
- answer ๋ฐฐ์ด์ sorted() ๋ฉ์๋๋ฅผ ํ์ฉํ์ฌ ์ ๋ ฌ
- for ๋ฌธ์ ํ์ฉํ์ฌ print
let line = Array(readLine()!)
var answer: [String] = []
for i in 0..<line.count {
var word = ""
for j in i..<line.count {
word += String(line[j])
}
answer.append(word)
}
answer = answer.sorted()
for a in answer {
print(a)
}
๋ฐ์ํ
'Algorithm > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค] (Swift) 9613๋ฒ - GCDํฉ (0) | 2022.02.20 |
---|---|
[๋ฐฑ์ค] (Swift) 17087๋ฒ - ์จ๋ฐ๊ผญ์ง6 (๋ฌธ์ ํ์ด ์ค๋ช , GCD์๊ณ ๋ฆฌ์ฆ_์ค์ํํธ) (0) | 2022.02.19 |
[๋ฐฑ์ค] (Swift) 10824๋ฒ - ๋ค ์ (0) | 2022.02.18 |
[๋ฐฑ์ค] (Swift) 11655๋ฒ - ROT13 (0) | 2022.02.17 |
[๋ฐฑ์ค] (Swift) 10820๋ฒ - ๋ฌธ์์ด ๋ถ์ (0) | 2022.02.16 |