题解 | #字符串分隔#

字符串分隔

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

function zero(num){
    let res = '0';
    for(let i=0;i<num;i++){
        res+='0';
    }
    return res;
}
let str;
while(str = readline()){
    str+=zero(8-str.length%8);
    const num = str.length/8;
    for(let i=0;i<num-1;i++){
        const res = str.slice(8*i,8*(i+1));
        if(res !== '00000000'){
        console.log(res);
        }
    }
}

全部评论

相关推荐

评论
点赞
1
分享

创作者周榜

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