알고리즘

Javascript로 백준에서 문제풀기 (Node.js)

또롱또 2022. 5. 13. 09:14
728x90

1. Node Js 설치

2. 설치됬나 체크

 

// 터미널 키워드
node

3. 파일 만들기 - js파일 / input 파일

4. input파일에 아무 숫자나 문자 쓰고 저장

5. js파일에 아래 코드 입력후 저장

const fs = require('fs');
const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';
let input = fs.readFileSync(filePath).toString().split(' ');

let a = input[0];

console.log(a);

6. node 파일이름.js 하면 터미널에 input에 입력한 값이 나옴

728x90