题解 | #字符串分隔#

字符串分隔

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
}

全部评论

相关推荐

轻絵梨花泪沾衣:南泵,大少爷驾到通通闪开
点赞 评论 收藏
分享
09-14 17:23
门头沟学院
故事和酒66:所以说副业很重要,程序员干到40岁,再怎么也赚300万了,吃吃利息也够活下去
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务