JS node 题解 | #字符串分隔#

字符串分隔

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

const rl = require("readline").createInterface({ 
    input: process.stdin,
    output: process.stfout
});
// 输入单行
rl.on('line', function(line) {
    if (line.length === 0) {
        console.log(line)
        return
    }
    if (line.length % 8 !== 0) {
        const tmp = []
        for (let i=0;i<(8-(line.length % 8));i++) {
            tmp.push('0')
        }
        let newlist = tmp.join().replace(/,/g, '')
        const formatList = line.concat(newlist)
        for (let i=0; i<(formatList.length/8);i++) {
            console.log(formatList.substr(i*8, 8))
        }
    } else {
        for (let i=0; i<(line.length/8);i++) {
            console.log(line.substr(i*8, 8))
        }
    }
})

全部评论

相关推荐

小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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