题解 | #字符串分隔#

字符串分隔

http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7

while(line = readline()){
const lineRes=sliceString(line)
for(let o of lineRes){
console.log(o)
}
}
function sliceString(str){
const count = Math.ceil(str.length/8)
const res=[]
for(let i=0;i<count;i++){
let slice= str.substring( i8 , i8 + 8 )
if(slice.length<8){
slice= new Array(8).fill(0).map((i,index)=>slice[index]?slice[index]:i).join('')
}
res.push(slice)
}
return res
}

全部评论

相关推荐

04-21 11:22
已编辑
中华女子学院 UE4
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务