백준에서 입력값 받기

남성윤·2024년 1월 21일
0

학습 일지

목록 보기
345/369

백준에서 Node.js로 입력을 받는 방법은 크게 두 가지가 있다.

readline 모듈
fs 모듈
readline보다 fs모듈을 사용하는 것이 더 빠르다.

const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt"
const input = require("fs").readFileSync(filePath).toString().trim().split(" ")
var fs = require('fs');
var input = fs.readFileSync('/dev/stdin').toString().split(' ');
profile
안녕하세요, Blog 2022.06 ~

0개의 댓글