본문 바로가기

프로그래머스(코딩 테스트)/Lv.0

홀짝 구분하기

 

// javascript
const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (line) => {
    const n = Number(line.trim());
    const preparedString = (n % 2 === 0) ? 'even' : 'odd';
    console.log(`${n} is ${preparedString}`);
}).on('close', () => {
    process.exit();
});

 

// typescript
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (line: string) => {
    const n: number = Number(line.trim());
    const preparedString: string = (n % 2 === 0) ? 'even' : 'odd'; 
    console.log(`${n} is ${preparedString}`);
}).on('close', () => {
    process.exit();
});

'프로그래머스(코딩 테스트) > Lv.0' 카테고리의 다른 글

정수 찾기  (0) 2024.10.20
조건에 맞게 수열 변환하기 3  (0) 2024.10.20
덧셈식 출력하기  (0) 2024.10.20
배열 비교하기  (0) 2024.10.19
주사위 게임 1  (0) 2024.10.19