ํ๋ก๊ทธ๋๋ฐ/์๊ณ ๋ฆฌ์ฆ ํ์ด Swift
[๋ฐฑ์ค 3047] ABC (Swift)
๋น๋น bibi
2022. 10. 12. 11:59
์ฒซ ์ค ์ ๋ ฅ์์ A < B < C ์ธ ์ A, B, C๋ฅผ ์ฐพ๊ณ
๋๋ฒ์งธ ์ค ์ ๋ ฅ์์ ์ฃผ์ด์ง๋ ์์๋๋ก A, B, C๋ฅผ ์ถ๋ ฅํ๋ ๋ฌธ์
- ์ฒซ ์
๋ ฅ ๋ฐ์ ๋ Int๋ก ์บ์คํ
์ํด๋ ๋๋? ํด์ ์ํ๋๋ฐ, ๊ทธ๊ฑด ํ ์๋ฆฌ ์ ๊ธฐ์ค์์๋ง ์ฑ๋ฆฝํ๊ณ , ์ฌ๋ฌ ์๋ฆฌ ์ ์ ๋ ฌํ ๋๋ ๋ฐ๋์ Int๋ก ๋ณํํด์ค์ผ ํ๋ค.
- String ์ ๋ ฌ : 1, 4, 3 โ 1, 3, 4 (O) / 1, 9, 11 โ 1, 11, 9 (X)
- Int ์ ๋ ฌ : 1, 4, 3 โ 1, 3, 4 (O) / 1, 9, 11 โ 1, 9, 11 (O)
ํ์ด
var input = readLine()!.split(separator: " ").map { Int($0)! }
input = input.sorted()
let order = readLine()!
for char in order {
switch char {
case "A":
print(input[0], terminator: " ")
case "B":
print(input[1], terminator: " ")
case "C":
print(input[2], terminator: " ")
default:
break
}
}