티스토리 뷰
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | let input = readLine()! var offset: Int = 0 var startIndex = input.startIndex if(input.count < 10){ print(input) } else{ offset = 10 var endIndex = input.index(startIndex, offsetBy: offset) while(offset == 10){ print(input[startIndex..<endIndex]) startIndex = endIndex if(input[endIndex..<input.endIndex].count < 10){ offset = input.count - endIndex.encodedOffset } else{ offset = 10 } endIndex = input.index(startIndex, offsetBy: offset) } if(input[startIndex..<endIndex].count != 10 && input[startIndex..<endIndex].count != 0){ print(input[startIndex..<endIndex]) } } | cs |
'Algorithm > Baekjoon Online Judge' 카테고리의 다른 글
2108번 '통계학' (0) | 2018.02.23 |
---|---|
1427번 '소트인사이드' (0) | 2018.02.23 |
11720번 '숫자의 합' (0) | 2018.02.23 |
11719번 '그대로 출력하기 2' (0) | 2018.02.23 |
11718번 '그대로 출력하기' (0) | 2018.02.23 |
댓글