看了一圈这个应该是js最简洁的写法,简单易懂,用obj存储和计算还不需要排序,直接使用Object.entries输出完事 var readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const obj = {} rl.on('line', function(line){ var tokens = line.split(' '); if(tokens[1]){ ...