题解 | #字符串分隔#

字符串分隔

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

const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void (async function () {
    // Write your code here
    while ((line = await readline())) {
        let tLine = line;
        let t = 0;
        let str = "";
        for (let i = 0; i < tLine.length; i++) {
            if (t < 8) {
                str = str.concat(tLine[i]);
                t++;
            } else {
                console.log(str);
                str = tLine[i];
                t = 1;
            }
            if (t < 8 && i === tLine.length - 1) {
                for (let j = t; j < 8; j++) {
                    str = str.concat("0");
                }
            }
        }
        console.log(str);
    }
})();

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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