티스토리 뷰
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | enum Day: Int{ case SUN = 6 case MON = 0 case TUE = 1 case WED = 2 case THU = 3 case FRI = 4 case SAT = 5 } let daysOfMonth: [Int: Int] = [1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31] let input = readLine()?.split(separator: " ") let x = Int((input?.first?.description)!)! let y = Int((input?.last?.description)!)! var count = 0 for i in 1..<x{ count += daysOfMonth[i]! } count += y count -= 1 print(Day.init(rawValue: count % 7)!) | cs |
결과값 출력을 위해 열거형을 사용해 보았다.
'Algorithm > Baekjoon Online Judge' 카테고리의 다른 글
1978번 '소수 찾기' (0) | 2018.02.22 |
---|---|
1977번 '완전제곱수' (0) | 2018.02.22 |
1546번 '평균' (0) | 2018.02.22 |
1316번 '그룹 단어 체커' (0) | 2018.02.22 |
1193번 '분수찾기' (0) | 2018.02.22 |
댓글