[백준2753_자바스크립트(javascript)] - 윤년

경이·2024년 1월 9일

𝑩𝑶𝑱 (𝒋𝒔)

목록 보기
12/325

🔴 문제

윤년


🟡 Sol

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

let input = [];

readline
  .on('line', (line) => {
    input = line.split(' ');
    readline.close();
  })
  .on('close', () => {
    solutiuon(input);
    process.exit();
  });

function solutiuon(input) {
  const year = parseInt(input);

  if (year % 400 === 0) console.log(1);
  else if (year % 100 !== 0 && year % 4 === 0) console.log(1);
  else console.log(0);
}

🟢 풀이

&& 앰퍼센트 논리연산자 사용하면된다.


🔵 Ref

profile
록타르오가르

0개의 댓글