BOJ_3단계 11021번 A+B - 7

Daniel Lim·2021년 5월 11일
0

문제풀이

목록 보기
16/19
post-thumbnail

15552번하고 비슷한 문제이다.

다만 출력시 결과값 앞에 Case번호를 붙여서 출력되게 해야한다.

Case #1: 2
Case #2: 5
Case #3: 7
Case #4: 17
Case #5: 7
const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

const array = [];
let result = '';

const onInput = (input) => array.push(input);

const onClose = () => {
    for (let i = 1; i <= array[0]; i++){
        const [a, b] = array[i].split(' ');
        result += `Case #${i}: ${Number(a) + Number(b)}\n`;
      // 문자열과 변수입력까지 가능한 백틱을 이용하면 된다.
    }
    console.log(result);
    process.exit();
}

rl.on('line', onInput).on('close', onClose);
profile
웹개발 잘하고 싶어요

0개의 댓글