Bibi's DevLog ๐ค๐
[๋ฐฑ์ค 25024] ์๊ฐ๊ณผ ๋ ์ง (Swift) ๋ณธ๋ฌธ
ํ๋ก๊ทธ๋๋ฐ/์๊ณ ๋ฆฌ์ฆ ํ์ด Swift
[๋ฐฑ์ค 25024] ์๊ฐ๊ณผ ๋ ์ง (Swift)
๋น๋น bibi 2022. 9. 17. 10:39- ์๊ฐ : 0-23, ๋ถ : 0-59
- ์ : 1-12
- ์ผ : ์๋ณ๋ก ๋ค๋ฅด๊ฒ ์ ์ฉ
์์ผ ๋๋ผ์ง๋ง ์ค์ํํธ์์ Range์ switch ๋ค์ค case ์ฌ์ฉ์ด ๊ฐ๋ฅํด์ ์ฐธ ํธํ ๊ฒ ๊ฐ๋ค.
ํ์ด
let inputCount = Int(readLine()!)!
(1...inputCount).forEach { _ in
let inputArr = readLine()!.split(separator: " ").map { Int($0)! }
var isTime = false
var isDate = false
if (0...23).contains(inputArr[0])
&& (0...59).contains(inputArr[1]) {
isTime = true
}
if (1...12).contains(inputArr[0]) {
switch inputArr[0] {
case 1, 3, 5, 7, 8, 10, 12:
if (1...31).contains(inputArr[1]) {
isDate = true
}
case 4, 6, 9, 11:
if (1...30).contains(inputArr[1]) {
isDate = true
}
case 2:
if (1...29).contains(inputArr[1]) {
isDate = true
}
default:
break
}
}
print("\(isTime ? "Yes" : "No") \(isDate ? "Yes" : "No")")
}
'ํ๋ก๊ทธ๋๋ฐ > ์๊ณ ๋ฆฌ์ฆ ํ์ด Swift' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค 25191] ์นํจ๋์ค๋ฅผ ์ถ๋ ๊ณฐ๊ณฐ์ด๋ฅผ ๋ณธ ์์ค (Swift) (0) | 2022.09.19 |
---|---|
[๋ฐฑ์ค 2576] ํ์ (Swift) (0) | 2022.09.17 |
[๋ฐฑ์ค 2566] ์ต๋๊ฐ (Swift) (0) | 2022.09.15 |
[๋ฐฑ์ค 2562] ์ต๋๊ฐ (Swift) (0) | 2022.09.14 |
[๋ฐฑ์ค 2490] ์ท๋์ด (1) | 2022.09.13 |