题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
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 const ifIsOpen = (isNaN, isOPen, str, i) => { let tempOpen = isNaN ? isOPen : !isOPen; if (tempOpen) { str = str.concat("*"); isOPen = !isOPen; } return { // return多个参数 str: str.concat(i), isOPen, }; }; while ((line = await readline())) { let str = ""; let isOPen = false; for (let i = 0; i < line.length; i++) { let obj = ifIsOpen(isNaN(line[i]), isOPen, str, line[i]); str = obj.str; isOPen = obj.isOPen; if (!isNaN(line[i]) && i === line.length - 1) str = str.concat("*"); } console.log(str); } })();