2023. 7. 23. 16:46ใStudy_Develop/์๊ณ ๋ฆฌ์ฆ | ์ฝ๋ฉํ ์คํธ
ํ์ด >
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let input = [];
rl.on('line', function (line) {
input = line.split(' ');
}).on('close', function () {
console.log(`a = ${Number(input[0])}\nb = ${Number(input[1])}`);
});
ํด์ค:
- input ์ด๋ผ๋ ๋ฐฐ์ด์ ์ด๊ธฐํ ํ์ฌ ์ฌ์ฉ์์ ์ ๋ ฅ์ ์ ์ฅ
- rl.on("line", ...)๋ฉ์๋๋ line์ด๋ฒคํธ์ ๋ํ ์ด๋ฒคํธ๋ฆฌ์ค๋๋ฅผ ์ค์
์ฌ์ฉ์๊ฐ ํ์ค์ ์ ๋ ฅ์ ์ ๋ ฅํ๊ณ enterํค๋ฅผ ๋๋ฅด๋ฉด ํธ๋ฆฌ๊ฑฐ ๋๋ค.
- ์ด ์ด๋ฒคํธ๊ฐ ํธ๋ฆฌ๊ฑฐ ๋๋ฉด ์ ๋ ฅ์ ๊ณต๋ฐฑ ๋ฌธ์๋ฅผ ๊ตฌ๋ถ์๋ก ์ฌ์ฉํ์ฌ
๋จ์ด ๋ฐฐ์ด๋ก ๋ถ๋ฆฌ๋๊ณ ๊ฒฐ๊ณผ๊ฐ input์ ์ ์ฅ๋๋ค.
โผ๏ธ readline์ฌ์ฉ๋ฒ์
https://dlawlgus40.tistory.com/47
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฌธ์์ด ์ถ๋ ฅํ๊ธฐ JavaScript (feat. readline์ฌ์ฉ๋ฒ)
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฌธ์์ด ์ถ๋ ฅํ๊ธฐ JavaScript (feat. readline์ฌ์ฉ๋ฒ) ๋ฌธ์ > ํด๊ฒฐ ๋ฐฉ๋ฒ> const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); let input = []; rl.on('line
dlawlgus40.tistory.com
์๊ธฐ์์๋ ์ ๋ฆฌํ์ผ๋ ์๋ต!