카타 7급 Get the Middle Character

1 Kotlin[ | ]

2 R[ | ]

get_middle <- function(s){
  substr(s, (nchar(s)+1)%/%2, nchar(s)%/%2 + 1)
}
get_middle <- function(s){
  n = nchar(s)
  if( n %% 2 == 0 ) substr(s, n/2, n/2+1)
  else substr(s, (n+1)/2, (n+1)/2)
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}