[JS] 백준 11021번 A+B-7

jsg_ko·2021년 11월 11일
0

코테연습

목록 보기
7/21
const fs = require("fs"); //파일받기위해 필요
const localFile = fs.existsSync("./input.txt"); // 내가 알고리즘 풀려는 폴더에 './input.txt'의 유무를 참,거짓으로 변수에 넣어라
#### const filePath = () => {
  // 참이면 내 input파일을 열고 그외는 백준의 알고리즘에서 주는 입력값을 받겠다.
  if (localFile) {
    return "./input.txt";
  }
  return "/dev/stdin";
};
var input = fs.readFileSync(filePath()).toString().trim().split('\n');

const T = Number(input[0])

for (let i = 1; i <= T; i++){
  let input1 = input[i].split(' ')[0]
  let input2 = input[i].split(' ')[1]
  console.log(`Case #${i}: ${ Number( input1 )  +  Number(input2 )
}`)
} 
profile
디버깅에서 재미를 추구하면 안되는 걸까

0개의 댓글

Powered by GraphCDN, the GraphQL CDN