karkar's blog

By karkar, history, 9 months ago, In Russian,

To test the code:

http://codeforces.com/problemset/customtest (select Node.js)

To output:

console.log('your output text here'); 

To input:

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    console.log(lines);    
})
 
 
 
 
  • Vote: I like it
  • +13
  • Vote: I do not like it

»
3 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it
const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

// single line input
readline.on('line', line => {
  readline.close(), console.log(line);
});

// multi line input
readline.on('line', line => {
  console.log(line);
});