2753번: 윤년
연도가 주어졌을 때, 윤년이면 1, 아니면 0을 출력하는 프로그램을 작성하시오. 윤년은 연도가 4의 배수이면서, 100의 배수가 아닐 때 또는 400의 배수일 때이다. 예를 들어, 2012년은 4의 배수이면서
www.acmicpc.net
문제풀이
const fs = require("fs");
BOJkey = 0;
let input = fs
.readFileSync(BOJkey ? "./자바스크립트로/2753/input.txt" : "./dev/stdin")
.toString()
.trim();
input = +input;
if (input % 4 === 0) {
if (input % 100 === 0) {
if (input % 400 === 0) {
console.log(1);
} else {
console.log(0);
}
} else {
console.log(1);
}
} else {
console.log(0);
}
'공부기록 > 자바스크립트 코딩테스트' 카테고리의 다른 글
자바스크립트 여러개의 값 반환하기 (0) | 2022.07.06 |
---|---|
if문 중첩에 관한 고찰 (0) | 2022.07.06 |
[백준/Python] 1655 가운데를 말해요 (0) | 2022.07.05 |
[백준/Python] 2075번 N번째 큰수 (0) | 2022.07.05 |
[백준/11286] 11286 절대값 힙 (0) | 2022.07.05 |