题解 | #字符串分隔#
字符串分隔
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
}