我尝试过使用" readline"但我得到的错误如下:
你可以看到我只是想从控制台读取一个值。
solution.js:5
var input_stdin_array = "";
var input_currentline = 0;
function readLine(){return input_stdin_array [input_currentline ++];}
function processData(input){
var M = parseDouble(readLine());
console.log("M : "+M-1);
var T = parseInt(readLine());
var X = parseInt(readLine());
var final_price = M + ((T*12)/100) + ((X*12)/100);
console.log("The final price of the meal is $"+final_price);
}
process.stdin.resume();
process.stdin.setEncoding(" ASCII&#34);
_input ="&#34 ;;
process.stdin.on(" data",function(input){
_input += input;
});
process.stdin.on(" end",function(){
过程数据(_Input);
});
^
ReferenceError:未定义readLine at processData(solution.js:5:22)
at ReadStream.<anonymous> (solution.js:20:4)
at emitNone (events.js:72:20)
at ReadStream.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:905:12)
at doNTCallback2 (node.js:452:9)
at process._tickCallback (node.js:366:17)