Blue Bridge cup of java-based exercise judgment leap year

Basic exercises judgment leap year

Resource constraints

Time limit: 1.0s Memory Limit: 256.0MB

Problem Description

Given a year to determine the year is not a leap year.

When one of the following conditions are met this year is a leap year:

  1. Year is a multiple of 4 but not multiple of 100;

  2. Year is a multiple of 400.

Other years are not leap years.

Input Format

Input contains an integer y, it represents the current year.

Output Format

Output line, if the given year is a leap year, the output yes, otherwise output no.
Note: When you export a string of questions specified as a result (such as this question yes or no, you need to strictly follow the questions in a given case, wrong case will not score points.

Sample input

2013

Sample Output

no

Sample input

2016

Sample Output

yes

Data size and convention

1990 <= y <= 2050。

import java.util.Scanner;
public class Main{
    public static void main(String[] args) {        
        int year;
        Scanner scanner=new Scanner(System.in);
        year=scanner.nextInt();
        if(year%4==0 && year%100!=0 || year%400==0){
            System.out.println("yes");
        }else{
            System.out.println("no");
        }
    }
    
}
Published 24 original articles · won praise 2 · Views 181

Guess you like

Origin blog.csdn.net/weixin_44570019/article/details/104515743