BOJ | #10950 "A+B"

블로그 이사 완료·2022년 9월 23일
0
post-thumbnail

문제


Code

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

input.shift().split(',');

let answer = [];
for (let i = 0; i < input.length; i++) {
  answer = input[i].split(' ').map(Number);
  console.log(answer[0] + answer[1]);
}

Review

한줄씩 주어진 숫자를 하나의 배열로 변환하고, 처음 주어진 테스트 수는 shift() 로 지웠다. for문으로 배열을 돌면서 한칸씩 띄어진 두 수를 새로운 배열에 넣었다. 그리고 두 수를 더한 값을 출력했다.

배열의 함수들을 더 많이 공부해야 코테에 나오는 문제들을 해석한대로 잘 풀 수 있을 듯 싶다.


profile
https://kyledev.tistory.com/

0개의 댓글