[Node.js/JavaScript] ๋ฐฑ์ค€ Node.js๋กœ ์ž…์ถœ๋ ฅ ํ•˜๋Š” ๋ฐฉ๋ฒ•
ยท
Algorithm/๋ฐฑ์ค€(BOJ)
์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋ฅผ ์ฒ˜์Œ ํ’€์–ด๋ณด๊ธฐ ์œ„ํ•ด ๋ฐฑ์ค€ ์‚ฌ์ดํŠธ๋ฅผ ์„ ํƒํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋ฐฑ์ค€์—์„œ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋ฅผ ํ’€๊ธฐ ์œ„ํ•ด์„œ๋Š” Node.js๋ฅผ ์„ ํƒํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ฒ˜์Œ ๋ฐฑ์ค€ ์‚ฌ์ดํŠธ์—์„œ ํ’€์–ด๋ณด์‹ ๋ถ„๋“ค์€ ์•„์‹œ๊ฒ ์ง€๋งŒ ํ•จ์ˆ˜๋งŒ ๋‹ฌ๋ž‘ ์ ์–ด๋†“๊ณ  ์ œ์ถœํ•˜๋ฉด ๋Ÿฐํƒ€์ž„ ์˜ค๋ฅ˜๊ฐ€ ๋œน๋‹ˆ๋‹ค. ๋ฐฑ์ค€ ์‚ฌ์ดํŠธ์—์„œ๋Š” ๋‹ค๋ฅธ ์‚ฌ์ดํŠธ๋“ค๊ณผ ๋‹ฌ๋ฆฌ ์ž…๋ ฅ๊ณผ ์ถœ๋ ฅ์„ ์ง์ ‘ํ•ด์ฃผ์–ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๋ฐฑ์ค€์—์„œ Node.js๋กœ ์ž…๋ ฅ์„ ๋ฐ›๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ readline ๋ชจ๋“ˆ๊ณผ fs ๋ชจ๋“ˆ ๋‘๊ฐ€์ง€๊ฐ€ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์ €๋Š” ๋ฐฑ์ค€ ์‚ฌ์ดํŠธ ๋„์›€๋ง์— ์žˆ๋Š” fs ๋ชจ๋“ˆ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค. (readline ๋ชจ๋“ˆ๋ณด๋‹ค ์ฒ˜๋ฆฌ์†๋„๊ฐ€ ๋น ๋ฅด๋‹ค.) // fs = ํŒŒ์ผ ์ž…์ถœ๋ ฅ ์ฒ˜๋ฆฌ, 'dev/stdin'ํŒŒ์ผ์—์„œ ์ž…์ถœ๋ ฅ์„ ๊ฐ€์ ธ์™€์„œ ๊ณต๋ฐฑ์„ ๊ธฐ์ค€์œผ๋กœ ์ž˜๋ผ์ค€๋‹ค. var fs = require('fs'); var input =..
_์„ฑํ˜ธ_
'JavaScript ์ž…์ถœ๋ ฅ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก