언젠가는 펼쳐 볼 아카이브

[BOJ] 10952번 - A+B - 5 본문

IT/Baekjoon Oline Judge

[BOJ] 10952번 - A+B - 5

개발자희망생고롸파덕 2023. 8. 16. 18:31

사용언어 : javascript - node.js

# 제출 코드

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

const testCaseArray = [];
for (let i = 0; ; ++i) {
  const tempValue = input[i].split(' ').map((item) => +item);
  testCaseArray.push({ A: tempValue[0], B: tempValue[1] });
  if (tempValue[0] === 0 && tempValue[1] === 0) {
    break;
  }
}

solution(testCaseArray);

function solution(testCaseArray) {
  let a = testCaseArray[0].A;
  let b = testCaseArray[0].B;
  let idx = 1;

  while (a !== 0 || b !== 0) {
    console.log(a + b);
    a = testCaseArray[idx].A;
    b = testCaseArray[idx].B;
    idx++;
  }
}

'IT > Baekjoon Oline Judge' 카테고리의 다른 글

[BOJ] 10807번 - 개수 세기  (0) 2023.08.16
[BOJ] 10951번 - A+B - 4  (0) 2023.08.16
[BOJ] 11022번 - A+B - 8  (0) 2023.08.16
[BOJ] 11201번 - A+B - 7  (0) 2023.08.16
15552번 - 빠른 A+B  (0) 2023.08.16