题解 | #参数解析#
参数解析
https://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function () {
const line = await readline();
let quot = false,list = [],str = "";
for(const c of line){
if(c ==="\""){
if(quot){
list.push(str);
str = "";
}
quot = !quot;
}else if(c ===" "){
if(quot) {
str+=c;
}else if(str){
list.push(str);
str = "";
}
}else {
str += c;
}
}
if(str) list.push(str);
console.log(list.length);
console.log(list.join("\n"));
}()
查看11道真题和解析