알고리즘/백준(backjoon)

[Baekjoon]백준 NO.2753 - 윤년 / Java(자바)

씨네 2021. 4. 27. 12:16
728x90

윤년 평년 구하는 문제이다.

 

윤년과 평년의 조건은 문제에 잘 나와있다...

 

학원수업에서 달력코드를 짠게 있어서 그때 수업한게 매우 도움이 되어 쉽게 문제를 풀수 있었다.

//No.2753
package com.bj02.If;

import java.util.Scanner;

public class Main03 {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
			
		int year = sc.nextInt();
		int res = 0;
		
		if( (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0) ) {
			res = 1;
		}
		
		System.out.println(res);
		
		sc.close();
	}
}
728x90