[백준 11021번/node.js] A+B -7

김겜김·2023년 11월 3일
0

문제

입력값

문제해결 방법
A+B를 반복문안에서 해결할려고했고 백틱(``),달러($) 사용해서 풀어야겠다고 생각하였고 numbers변수를 반복문 밖에서 선언하다보니 조금 복잡해져서 반복문 안에서 문제를 풀어볼려고 생각해보면서 해결해 보았습니다.

코드

const fs = require('fs');

//백준 제출용
// const input = fs.readFileSync("/dev/stdin").toString().split('\n');

//문제풀이용
const input = fs.readFileSync('example.txt').toString().split('\n');

for (let i = 1; i <= input[0]; i++) {
  let numbers = input[i].split(' ');

  console.log(`Case #${i}: ${Number(numbers[0]) + Number(numbers[1])}`);
}

출력

profile
개발에 관심이있습니다

0개의 댓글