๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

ํ”„์—” ๊ณต๋ถ€/๐Ÿซง ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ณต๋ถ€

[๋ฐฑ์ค€/Node.js] 11021, 11022๋ฒˆ ํ’€์ด || JavaScript

728x90

#11021

let input = require('fs').readFileSync('/dev/stdin').toString().split("\n");
const loop = +input[0];

for (i = 1; i <= loop; i++) {
    let numbers = input[i].split(" ").map(Number);
    console.log(`Case #${i}: ${numbers[0] + numbers[1]}`);
}

 

๋ฐ›์•„์˜จ input์˜ ๋‘๋ฒˆ์งธ ์ธ์ž๋ถ€ํ„ฐ split์œผ๋กœ ๋‚˜๋ˆ„๊ธฐ numers[0] numbers[1]

-> Number๋กœ ํƒ€์ž… ๋ณ€ํ™˜ ํ›„ ๋”ํ•ด์ค€ ๊ฐ’์„ ํ•˜๋‚˜์”ฉ ์ถœ๋ ฅ๋˜๊ฒŒ ํ•ด์ค€๋‹ค. 

 

#11022

for (i = 1; i <= loop; i++) {
    let numbers = input[i].split(" ").map(Number);
    console.log(`Case #${i}: ${numbers[0]} + ${numbers[1]} = ${numbers[0] + numbers[1]}`);
}

์œ„์˜ ๋ฌธ์ œ์™€ ๊ฐ™์€ ๋งฅ๋ฝ์ด๊ณ , ์ถœ๋ ฅํ•˜๋Š” ์ธ์ž๋งŒ ๋Š˜๋ ค ์‹์œผ๋กœ ์ถœ๋ ฅํ•ด์ฃผ๋ฉด ๋œ๋‹ค. 

 

 

 

728x90
๋ฐ˜์‘ํ˜•